Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.4

Bug #1084 parseSelectors incorrectly assumes selector structure
Submitted: 2004-03-27 16:03 UTC
From: matt at sensibleerection dot com Assigned: thesaur
Status: Closed Package: HTML_CSS
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2004-03-27 16:03 UTC] matt at sensibleerection dot com
Description: ------------ parseSelectors allows only one instance of each of element, class, id and pseudo in a selector, and presumes a specific order. Reproduce code: --------------- require_once( "HTML/CSS.php" ); $css = new HTML_CSS; $a = $css->parseSelectors( "#heading .shortname" ); $b = $css->parseSelectors( "#heading .icon" ); $c = $css->parseSelectors( "#heading .icon img" ); Expected result: ---------------- #heading .shortname #heading .icon #heading .icon img Actual result: -------------- #heading #heading #heading

Comments

 [2004-03-27 21:46 UTC] thesaur at php dot net
Yeah, I knew there was a problem, but I wasn't exactly sure how it should work in the end. The reason you see what you see is that there should be no reason why anyone needs to implement a class for an ID. Of course, dynamic pseudo classes are a different story (e.g., :hover). Then there is the issue of cascading style sheets which is at the center of your bug report. Selectors may be separated by spaces and then refer to a chain of conditions that must apply before the style is applied. I will rework the parseSelectors to parse each of the cascaded selectors, as well.
 [2004-03-29 04:16 UTC] matt at sensibleerection dot com
In this case it's not the id that's having a class applied, but a descendent of the id (The difference between "#heading.shortname" and "#heading .shortname". Note the space separator in the second.). Referring to a class descendent of an id does often make sense. As you may have several ".shortname" classed elements in the page, but you only want to refer to the ones that are descendents of "#heading".
 [2004-03-29 14:08 UTC] thesaur at php dot net
Which is what I was referring to as cascading selectors. Currently, cascading like that is disabled. But that does not mean that the class expects a certain order. It only places limitations on an individual selector, not space delimited selectors. The current (dumb) workaround is to use a class, because everything after the "." in the initial selector gets passed on unaltered. Of course, this is very unacceptable, but that's the workaround I can offer until I implement a comprehensive solution.
 [2004-05-18 18:58 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!