If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

CSS parser broken with ::selection

RESOLVED INVALID

Status

()

Firefox
Untriaged
RESOLVED INVALID
3 years ago
3 years ago

People

(Reporter: lorenzo.oz, Unassigned)

Tracking

32 Branch
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
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/

Comment 1

3 years ago
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
Last Resolved: 3 years ago
Resolution: --- → INVALID
(Reporter)

Comment 2

3 years ago
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 */
}

Comment 3

3 years ago
(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. "
(Reporter)

Comment 4

3 years ago
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.