Follow the spec more fully for ::first-letter range
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox139 | --- | fixed |
People
(Reporter: jfkthame, Assigned: jfkthame)
References
Details
Attachments
(2 files)
In bug 1944779 we made a change due to the recent CSSWG resolution to allow intervening space between punctuation and the actual letter when determining the range of the ::first-letter
pseudo.
However, more careful reading of the spec text reveals that the change was incomplete: the pattern described in the spec allows potentially multiple space-separated punctuation elements before the letter, and similarly after it, all to be included in the ::first-letter
pseudo. (With the caveat that after the letter, a word-separating space will end the ::first-letter
pseudo; but other Unicode whitespace may be included.)
Thus, in an extreme (and somewhat silly) example,
data:text/html;charset=utf-8,<style>::first-letter{background:cyan;font-size:2em}</style>
<p> - – — (&%23x2008;“&%23x2009;T&%23x2009;”&%23x2008;)&%23x2008;est
my understanding is that ::first-letter
should match everything up to and including the ")" character (but not the U+2008 "punctuation space" character following it).
(There isn't currently WPT coverage for stuff like this, but I notice that https://github.com/web-platform-tests/wpt/pull/51361 proposes to substantially extend ::first-letter coverage, including some cases with intervening space.)
Assignee | ||
Comment 1•4 months ago
|
||
And allow multiple punctuation elements, with potential intervening whitespace,
both before and after the letter.
Tests to be added once https://github.com/web-platform-tests/wpt/pull/51361 is merged.
Updated•4 months ago
|
Assignee | ||
Comment 2•4 months ago
|
||
Assignee | ||
Comment 5•4 months ago
|
||
Ah, right -- this is an expected behavior change. Back in bug 399941, we see:
From http://www.w3.org/TR/CSS21/selector.html#first-letter :
'Punctuation (i.e, characters defined in Unicode in the "open" (Ps), "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po) punctuation classes), that > precedes or follows the first letter should be included'
but the spec has since been further refined, and https://drafts.csswg.org/css-pseudo-4/#first-letter-pattern refers to:
Any punctuation other than opening punctuation and dashes—i.e. characters that belong to the Punctuation (P*) Unicode general category, excluding Open Punctuation (Ps) and Dash Punctuation (Pd)—that follows the first letter
Note the excluded subcategories of punctuation. So these tests need updating.
Assignee | ||
Comment 6•4 months ago
|
||
These tests are based on the CSS2 spec for ::first-letter, and no longer match the current
CSS Pseudos spec. Once the new and more comprehensive collection of tests in
https://github.com/web-platform-tests/wpt/pull/51361 is merged, it would probably make sense
to remove these as being obsolete, but for the time being I'm marking them as expected-fail.
Comment 8•4 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/5d0057a8beb9
https://hg.mozilla.org/mozilla-central/rev/d6b789099b1f
Updated•3 months ago
|
Description
•