Anchor relative :has() arguments to their subject - #201
Conversation
8b63327 to
36f19c8
Compare
nrps9909
left a comment
There was a problem hiding this comment.
Reviewed 36f19c8ab2b0dc230a7e5194a91507a55d0da3ad against eaf4233b2a7b4f950af7ad56ee0457be8e3d38d6.
The relative anchoring improvement holds in an independent Chromium 151.0.7922.34 comparison: 1,012 observations covering document/scoped/detached selection, repeated cached queries, and element matching. Base has 122 mismatches; head has zero. Cases include later sibling arguments, nested :is / :where, escaped commas, quoted comma values and outer :scope.
For the documented private-anchor isolation TODO, these public queries demonstrate the remaining regression:
nw.select(':-nwsapi-anchor', document); // []
nw.select('div:has(:-nwsapi-anchor)', document); // []
nw.select('div:not(:-nwsapi-anchor)', document); // all four divs in the fixtureBase and native Chromium throw SyntaxError for all three. Please keep the internal anchor out of public selector compilation, including nested logical selectors and cached queries, and add regressions for those paths before merge. Preserve the valid quoted-value control div:has([data-value=":-nwsapi-anchor"]): it matches the expected parent in both engines, so a blanket substring rejection would introduce another bug.
Validation: full Node suite 34 passed / two expected failures / one browser-only skip; the browser-enabled relative suite passes all 69 reference comparisons (three tests passed / two expected failures). Lint, formatting and packed-package checks pass; the package check runs 11 tests. The two inherited expected failures for nested :has() / pseudo-elements remain as documented. This review confirms the existing isolation TODO with concrete regressions; it does not claim those inherited validation gaps are new.
Validation performed with Codex assistance.
36f19c8 to
2a3fbae
Compare
|
Confirmed: the private pseudo was accepted by public compilation. Fixed in 8227098. Relative anchors now become generated code rather than selector syntax, with separate cache keys for relative and public compilation. Unit and WPT-harness tests cover all three reported queries, nested logical selectors, repeated cached queries, forgiving lists, and the valid quoted attribute control. Chromium agrees with the new results. The existing 69 relative-selector browser comparisons also pass. Removed 16 WPT expected failures that now pass. Full checks, package tests, and coverage pass locally; CI is running. The two inherited expected failures for nested :has() and pseudo-elements remain separate from this review fix. |
|
Verified the merged I expanded the isolation checks to document/scoped/detached contexts, three cache-reuse rounds, This appears to be the broader deferred argument-validation gap, rather than continued recognition of the private pseudo. With an unrelated const empty = document.createElement('div');
empty.matches('div:has(:not(:unknown))'); // native: SyntaxError
nw.match('div:has(:not(:unknown))', empty); // false on both versionsThat broader gap needs validation independent of candidate availability; valid On the documented Node 26 toolchain (26.8.1, pnpm 12.3.4), full Node tests pass 416 cases with two expected failures and five skips; browser tests pass 15 with the same two inherited expected failures; packed-package checks pass 22; all 44 configured WPT/fixture pages pass their expected-result checks. Reproduction artifact: standalone probe, instructions and results. The expanded corpus has 486 observations per version, including empty containers and detached elements: 174 mismatches on the previously reviewed head, 84 on the merged head, 90 resolved observations and zero new failing observations. All 270 valid/forgiving/quoted controls pass on the merged head. The 84 remaining mismatches represent 28 paths repeated across three cache rounds, including |
Change
Anchor every relative :has() argument to its subject, including later sibling arguments. Keep explicit :scope tied to the outer query and restore the previous anchor after success or exceptions.
The private-anchor review identified a real regression. The fix removes the private pseudo-selector entirely: anchors become generated code, and relative compilation uses separate cache keys. Unit and WPT tests reject the reported public and nested queries, preserve quoted attribute values, and cover repeated cached queries and forgiving lists.
Validation
The two inherited expected failures cover nested :has() and pseudo-element validation, not private-anchor isolation. See test/relative-has-testing.md for commands.