Skip to content

Backport :has() validation fixes to v2 - #216

Open
jdalton wants to merge 1 commit into
masterfrom
fix/has-validation-v2
Open

jdalton wants to merge 1 commit into
masterfrom
fix/has-validation-v2

Conversation

@jdalton

@jdalton jdalton commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Invalid :has() arguments can be accepted on empty queries, nested :has() can match, and wildcard namespaces are rejected on v2. Backport v3's eager logical validation and forgiving-branch handling so these selectors follow the same rules across all eight DOM selector APIs. Changing VERBOSITY also clears compiled failures so verbose retries throw correctly.

This preserves v2's released source layout, ES2015 syntax, and existing matching and cache architecture. It adds 18 focused regression tests and runs both maintenance suites through npm test.

Validation:

  • All 36 maintenance tests pass. The new suite reproduces 17 failures against the current master source.
  • All 112 subtests across seven pinned WPT :has() pages pass, up from 105 passing and seven failing. The same pages pass on v3. The separate :has-slotted pseudo-class is outside this backport.
  • WPT revision: fd983776a7cd19ebcda7a2bcb69c74330ee5d8c9, Chrome for Testing 154.0.8037.0. Parsing pages use the existing DOM selector-validity helper. Every selected subtest runs without result filtering.
  • node --check src/nwsapi.js and the existing ES2015 parse check pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant