Closed Bug 1074887 Opened 11 years ago Closed 11 years ago

CSS parser broken with ::selection

Categories

(Firefox :: Untriaged, defect)

32 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: lorenzo.oz, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:32.0) Gecko/20100101 Firefox/32.0 Build ID: 20140923175406 Steps to reproduce: I'm using this CSS: .myclass, ::selection { color: red; } Example: http://jsfiddle.net/7p7n8383/ Actual results: Text in elements with myclass class didn't change color. Example: http://jsfiddle.net/7p7n8383/ Expected results: Text in elements with myclass class should have been red. Example: http://jsfiddle.net/7p7n8383/
No, this is expected. See the warning in the console: Unknown pseudo-class or pseudo-element 'selection'. Ruleset ignored due to bad selector. The entire selector (including the bit before the 'or', ie the comma) is invalid because part of the selector is invalid. The same happens for any other invalid selector, e.g. http://jsbin.com/xasoyi/1/edit . This is what the spec requires. Firefox supports selection styling using ::-moz-selection .
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
Shouldn't firefox be more tollerable? To ignore an entire ruleset due to a single wrong selector is severe. Moreover this behaviour is inconsistent with this: .right-selector { color: red; unknown-rule: foo-bar; /* This is ignored and all other rules are applied */ }
(In reply to lorenzo.oz from comment #2) > Shouldn't firefox be more tollerable? > To ignore an entire ruleset due to a single wrong selector is severe. Chrome and IE do exactly the same if you specify broken selectors. As I said earlier, this is per-spec: http://www.w3.org/TR/CSS2/syndata.html#rule-sets "CSS 2.1 gives a special meaning to the comma (,) in selectors. However, since it is not known if the comma may acquire other meanings in future updates of CSS, the whole statement should be ignored if there is an error anywhere in the selector, even though the rest of the selector may look reasonable in CSS 2.1. "
I know, CSS3 uses the same spec in other terms: http://dev.w3.org/csswg/selectors4/#selector-list But... I'm not specifying broken selectors, I'm using valid CSS3 selectors that Firefox decided to support with different name. That should not be the same thing!
You need to log in before you can comment on or make changes to this bug.