Closed
Bug 1175192
Opened 9 years ago
Closed 9 years ago
Bug 985838 did not allow all identifiers to begin with two hyphens
Categories
(Core :: CSS Parsing and Computation, defect)
Core
CSS Parsing and Computation
Tracking
()
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox41 | --- | fixed |
People
(Reporter: Oriol, Assigned: bzbarsky)
References
Details
(Whiteboard: [parity-chrome] )
Attachments
(3 files)
According to bug 985838,
> idents in the CSS parser now allow things like "--"
I'm not entirely sure if that's true (the spec is not clear at all), but in any case, after fixing bug 985838, this selector works:
> [id=--]
However, this does not work:
> #--
This is problematic, because CSS.escape no longer escapes hyphens at the beginning, so the following may throw
> document.querySelector('#' + CSS.escape(id))
Note that, since Chromium implemented its new CSS parser (https://codereview.chromium.org/1015303002), it allows both #-- and [id=--]
Reporter | ||
Comment 1•9 years ago
|
||
Assignee | ||
Comment 2•9 years ago
|
||
> I'm not entirely sure if that's true (the spec is not clear at all)
Seems pretty clear for this case. In particular, http://dev.w3.org/csswg/css-syntax/#consume-token the U+0023 section uses http://dev.w3.org/csswg/css-syntax/#check-if-three-code-points-would-start-an-identifier which treats "--" as starting an identifier. So "#--" should create an "id" token per spec. Yay lack of test coverage. :(
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Comment 3•9 years ago
|
||
Attachment #8623180 -
Flags: review?(cam)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment 4•9 years ago
|
||
Looks like my one non-variable test change in test_parse_rule.html in bug 985838 was wholly inadequate.
There is another slight difference from the spec, although it's a real edge case. The three character sequence "-\\\n" should tokenize as '-' delim, '\\' delim (and an error), "\n" white space. But I think we currently tokenize it as '-' ident, '\\' delim, "\n" white space.
AFAICT the only place where a '\\' delim will not cause a parse error is in the value of a custom property. Because of the rules about inserting /**/ between certain adjacent tokens when expanding out var() functions, whether the '-' (incorrectly) becomes an ident or (correctly) becomes a delim can determine whether that /**/ is generated.
The attachment illustrates. I think the spec should require the computed value of --b to be serialized as "1-\\\nx", whereas we currently serialize it as "1/**/-\\\nx".
Do you want to fix that as part of this patch?
Flags: needinfo?(bzbarsky)
Assignee | ||
Comment 5•9 years ago
|
||
> There is another slight difference from the spec,
Ah, I tried to figure out where the third char bit was really needed and couldn't think of a place; I don't know the custom property parsing well enough.
I could go either way, but I suspect you're better positioned than me to figure out which all places need to check for the \n (e.g. the ones I'm touching don't seem to be related to custom property stuff)...
Flags: needinfo?(bzbarsky)
Updated•9 years ago
|
Attachment #8623180 -
Flags: review?(cam) → review+
Comment 6•9 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #5)
> I could go either way, but I suspect you're better positioned than me to
> figure out which all places need to check for the \n (e.g. the ones I'm
> touching don't seem to be related to custom property stuff)...
Sounds good, I filed bug 1175753 to do that.
Reporter | ||
Comment 7•9 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #2)
> Seems pretty clear for this case. In particular,
> http://dev.w3.org/csswg/css-syntax/#consume-token the U+0023 section uses
> http://dev.w3.org/csswg/css-syntax/#check-if-three-code-points-would-start-
> an-identifier which treats "--" as starting an identifier. So "#--" should
> create an "id" token per spec.
OK, thanks, I wasn't looking at the right spec.
Why hasn't your patch been implemented? Is bug 1175753 a dependency?
Assignee | ||
Comment 8•9 years ago
|
||
> Why hasn't your patch been implemented?
Oh, good catch. I thought I'd checked this in... Doing that now.
Comment 10•9 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox41:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in
before you can comment on or make changes to this bug.
Description
•