Closed Bug 1821258 Opened 1 year ago Closed 1 year ago

There are no reftests for :nth-child(.. of ) in SVG

Categories

(Core :: SVG, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: zrhoffman, Assigned: zrhoffman)

References

Details

Attachments

(1 file)

All of the tests for:nth-child(.. of ) so far seem to target HTML only and not SVG, but Selectors 4 applies for SVG, so that is missing test coverage.

At minimum, there should be reftests for :nth-child(.. of ) matching in SVG and :nth-child(.. of ) invalidation in SVG.

Summary: There are no reftests for `:nth-child(.. of )` in SVG → There are no reftests for :nth-child(.. of ) in SVG

Usually the only complicated thing about SVG and CSS is the <use> element and its use of a shadow tree. See https://www.w3.org/TR/SVG2/struct.html#UseStyleInheritance

Thanks for the direction, :longsonr! I made a couple of invalidation reftests (one for :nth-child(... of class) in SVG, one for :nth-last-child(... of class) in SVG) that use <use>, let me know what you think.

Component: CSS Parsing and Computation → SVG
Flags: needinfo?(longsonr)

These reftests will only pass if our :nth-child(.. of <selector>) and
:nth-last-child(.. of <selector>) invalidation considers DOM elements of
any type (including SVG elements), not only HTML elements.

Assignee: nobody → zach
Status: NEW → ASSIGNED

There's nothing wrong with these tests but the other thing to test is a selector that crosses the shadow boundary of the use element so

:nth-last-child(odd of use .c) should match nothing because use is outside the shadow dom but c is inside it so of now matches nothing at all (or should do).

https://www.w3.org/TR/SVG/struct.html#UseStyleInheritance

However, if a CSS rule uses a complex selector to match an element based on its ancestors or siblings, and those ancestors or siblings are not cloned as part of the shadow tree, then that rule would no longer match the element instance. Similarly, child-indexed pseudo-classes such as nth-of-type and nth-child may apply to one element but not the other. This represents a change from how style cloning was defined in previous versions of SVG.

I.e. the specification specifically references nth-child here so given it's explicitly mentioned, we really ought to test we do it right (I think we do).

Flags: needinfo?(longsonr)
Attachment #9323343 - Attachment description: Bug 1821258 - Add reftests for :nth-child(... of class) invalidation in SVG r?longsonr,#svg,#style → Bug 1821258 - Add reftests for :nth-child(... of <selector list>) in SVG r?longsonr,#svg,#style
Pushed by zach@zrhoffman.net:
https://hg.mozilla.org/integration/autoland/rev/82905658a3d0
Add reftests for :nth-child(... of <selector list>) in SVG r=longsonr,firefox-svg-reviewers
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/39046 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
Upstream PR merged by moz-wptsync-bot
Regressions: 1823013
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: