Closed Bug 4834 Opened 25 years ago Closed 25 years ago

too generous on pseudo-element matching

Categories

(Core :: CSS Parsing and Computation, defect, P3)

Other
Other
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: dbaron, Assigned: peterl-retired)

References

()

Details

You are being too generous on pseudo-element parsing.  There can't be a space
before the ":after".  See the above test, selector "P.four :after".

Other problems on this page are in bug 4833.
To be exact,

   P.four :after

...should be parsed as meaning the same as:

   P.four *:after

...i.e., it refers to the ":after" pseudo-element of *every* descendant of
any P elements with class=four. It does _not_, however, refer to the :after
pseudo-element of the P.four itself, which I guess is what is being done now
(I have not checked, though).
Yes.  I now think Ian is right.  I was looking at 5.10, which says:

    Pseudo-classes are allowed anywhere in selectors while pseudo-elements
    may only appear after the subject of the selector.

However, 5.3 says (I didn't see before how general this statement is)

    If the universal selector is not the only component of a simple selector,
    the "*" may be omitted.

This is *not* what you are currently doing.  I tested this by adding a
"P.four:after" rule after the "P.four :after" rule, and it overrode the first.

This applies to other pseudo-elements and pseudo-classes.  That is,

DIV :first-line  == DIV *:first-line
:first-letter == *:first-letter   (which only influences block-level elements)
P :before == P *:before
P :link == P *:link
A :link == A *:link   (useless?)

etc.
******** IGNORE EVERYTHING ABOVE THIS LINE. ********

The problem is not parsing.  The problem is in matching.  You are matching
descendant selectors of the form "A *:pseudo-element" as matching the :pseudo-
element of A or a descendant of A rather than only descendants of A (and not A
itself).

This shows up in the following test:

http://www.fas.harvard.edu/~dbaron/csstest/pseudos

in the selectors

div.two :first-line
div.six :before

As described in the test, the first line of the second test paragraph should
not be purple, and the words "Beginning of an Element" should not appear at the
beginning of the eighth paragraph.

cc:ing troy.  I'm not sure who should deal with this.
Status: NEW → ASSIGNED
Target Milestone: M5
Summary: too generous on pseudo-element parsing → too generous on pseudo-element matching
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Fixed. Now "foo:bar" turns into "foo > :bar" and "foo :bar" turns into "foo >
*:bar".
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.