LibWeb: Make :nth-* selectors match children of non-elements
Some checks failed
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled

This was covered by WPT, which caught us not allowing :nth-child(1)
to match the root HTML element, and other similar issues.
This commit is contained in:
Andreas Kling 2024-11-06 19:52:49 +01:00 committed by Andreas Kling
parent eeba30f988
commit 81e75530d9
Notes: github-actions[bot] 2024-11-06 20:43:45 +00:00
2 changed files with 19 additions and 19 deletions

View file

@ -6,8 +6,8 @@ Rerun
Found 54 tests
30 Pass
24 Fail
46 Pass
8 Fail
Details
Result Test Name MessagePass Expected HTML element to match :first-child with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :last-child with matches, querySelector(), and querySelectorAll()
@ -15,14 +15,14 @@ Pass Expected HTML element to match :only-child with matches, querySelector(), a
Pass Expected HTML element to match :first-of-type with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :last-of-type with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :only-of-type with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-child(1) with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-child(n) with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-last-child(1) with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-last-child(n) with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-of-type(1) with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-of-type(n) with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-last-of-type(1) with matches, querySelector(), and querySelectorAll()
Fail Expected HTML element to match :nth-last-of-type(n) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-child(1) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-child(n) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-last-child(1) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-last-child(n) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-of-type(1) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-of-type(n) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-last-of-type(1) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to match :nth-last-of-type(n) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to not match :nth-child(2) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to not match :nth-last-child(2) with matches, querySelector(), and querySelectorAll()
Pass Expected HTML element to not match :nth-of-type(2) with matches, querySelector(), and querySelectorAll()
@ -51,14 +51,14 @@ Pass Expected DIV element to match :only-child with matches, querySelector(), an
Pass Expected DIV element to match :first-of-type with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :last-of-type with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :only-of-type with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-child(1) with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-child(n) with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-last-child(1) with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-last-child(n) with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-of-type(1) with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-of-type(n) with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-last-of-type(1) with matches, querySelector(), and querySelectorAll()
Fail Expected DIV element to match :nth-last-of-type(n) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-child(1) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-child(n) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-last-child(1) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-last-child(n) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-of-type(1) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-of-type(n) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-last-of-type(1) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to match :nth-last-of-type(n) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to not match :nth-child(2) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to not match :nth-last-child(2) with matches, querySelector(), and querySelectorAll()
Pass Expected DIV element to not match :nth-of-type(2) with matches, querySelector(), and querySelectorAll()

View file

@ -517,7 +517,7 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
if (step_size == 0 && offset == 0)
return false; // "If both a and b are equal to zero, the pseudo-class represents no element in the document tree."
auto const* parent = element.parent_element();
auto const* parent = element.parent();
if (!parent)
return false;