Skip to content

Fix :has() sibling matching at root elements - #169

Closed
nrps9909 wants to merge 1 commit into
dperini:masterfrom
nrps9909:codex/guard-has-sibling-root
Closed

Fix :has() sibling matching at root elements#169
nrps9909 wants to merge 1 commit into
dperini:masterfrom
nrps9909:codex/guard-has-sibling-root

Conversation

@nrps9909

Copy link
Copy Markdown

Fixes #168.

This restores the parentElement guard before compiling adjacent- and general-sibling relational selectors inside :has(). Without it, matching a compound selector can reach the document root and dereference its null parent.

The new browser regression test covers both sibling forms at the root and a positive compound-selector case.

Validation:

  • node --check src/nwsapi.js
  • direct patched-source checks: root adjacent false, root general sibling false, compound sibling true
  • test/has-sibling-root.html under JSDOM: data-result=pass, no script errors
  • Ant Design #59151 exact head: released 2.2.25 fails 6/55 affected Tooltip tests; this local package passes 55/55 with 5 snapshots
  • git diff --check

The repository's current ESLint configuration reports 185 pre-existing errors across src/nwsapi.js when run with ES6 parsing; this patch does not introduce a new lint rule or broad cleanup.

AI assistance disclosure: Codex was used to trace and minimize the regression, prepare the focused patch and regression test, and draft this description. I reviewed the diff and reproduced all validation locally.

@nrps9909

nrps9909 commented Sep 6, 2026

Copy link
Copy Markdown
Author

The core root-sibling fix was incorporated into master in faa8468, which credits #169. Thank you!

I verified the adopted source and the published nwsapi@2.2.27 package today. Both pass ten direct root/detached-root/compound-selector checks; the original source and published 2.2.25 fail five of those checks. On Ant Design #59151 head 713b71aff63ccae4a0d9b797fe5504971288cad1, using the same dependencies and overriding only NWSAPI in the test process, 2.2.25 fails four of 52 Tooltip tests while published 2.2.27 passes all 52 with five snapshots (Node 24.15.0).

Closing this superseded PR because the runtime fix is already adopted and released. The standalone HTML fixture in this branch was not part of the maintainer's commit. This is manual incorporation, not a GitHub PR merge.

Validation performed with Codex assistance.

@nrps9909 nrps9909 closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in 2.2.25: :has() sibling selector throws on root elements

2 participants