mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-31 01:36:15 -04:00
Fixes the remaining 30 failing subtests of WPT
/dom/nodes/Element-matches.html, in five clusters:
Matching (selector/List.zig):
- :link now matches a and area elements with an href attribute (in a
headless browser no link is ever visited, so :visited stays
unmatched and :link covers every hyperlink). :any-link gains the
missing area case.
- :empty now ignores comment and processing-instruction children, per
Selectors Level 3 only elements and non-empty text/cdata affect
emptiness (<p><!-- comment --></p> is :empty, <p> </p> is not).
- :lang() is implemented: the element's language is the nearest
ancestor-or-self lang attribute, falling back to the UA default (en)
for elements in a document and to no language at all in detached
subtrees, which is what the WPT expects for the detached/fragment
contexts. Matching is ASCII case-insensitive on the exact tag or a
`-` separated prefix (:lang(en) matches lang="en-AU").
Parsing (selector/Parser.zig):
- An empty selector-list segment ("div," or ",div") is now a parse
error instead of being silently skipped.
- Unexpected EOF closes open attribute brackets per CSS Syntax:
'#attr-value [align="center"' parses and matches.
- Attribute selectors accept a namespace component: [*|TiTlE] (any
namespace) and [|title] (no namespace). Attributes are stored by
qualified name and almost never namespaced, so both forms match by
name; [*|*=test] stays invalid.
Coverage:
- /dom/nodes/Element-matches.html 639/669 -> 669/669 (fully green)
- /dom/nodes/ParentNode-querySelectors-namespaces.html 0/1 -> 1/1
- /dom/nodes/moveBefore/moveBefore-lang.html 0/1 -> 1/1
- /dom/nodes/moveBefore/Node-moveBefore.html 31/32 -> 32/32
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>