Return NodeList from querySelectorAll - #680
Conversation
df1cc5d to
61e85fe
Compare
61e85fe to
e08f0af
Compare
|
The scoped production change looks good at selectors.test.ts:243-260 assigns container.appendChild(document.createElement('p')).className = 'text';This polyfill does not implement Please use the supported attribute API and assert both the fresh and saved collections: container
.appendChild(document.createElement('p'))
.setAttribute('class', 'text');
expect(container.querySelectorAll('.text')).toHaveLength(4);
expect(matches).toHaveLength(3);Keep the existing order/iteration assertions. I independently verified this repaired fixture gives old 3 / fresh 4 on native, base, and head. No Otherwise, Validation: 288 polyfill tests and 59 focused core tests pass; all three new tests fail the actual base. The locked-TypeScript polyfill check passes head, while base plus the new tests has four expected type errors. All 30 scoped native collection/snapshot/bookkeeping checks match, and 279 selector-result cases are unchanged from #679, including its known gaps. Formatting and reported CI are green. Full-repository/live validation and upstream corrections remain separate gates. No source fix or approval performed. |
e08f0af to
914a468
Compare
914a468 to
00b081c
Compare
|
yea, the fixture wasn't adding a matching node. i switched it to |
Pull Request is not mergeable
Pull Request is not mergeable
Pull Request is not mergeable
Pull Request is not mergeable
00b081c to
b87b664
Compare
b87b664 to
5466415
Compare
Problem
querySelectorAll()collected matches in a plainArray, even though the polyfill provides aNodeListcollection with the DOM-compatibleitem()method. Array indexing,length, iteration, andforEach()happened to work, but callers using the standardNodeList.item()shape received a collection without that method.Impact
Minor. Feature-compatible selector code that calls
.item()on aquerySelectorAll()result threw at runtime instead of receiving the matching element ornullfor an out-of-range index.Reproduction
Before this change, the final call failed because
matcheswas a plain array. It now returns the paragraph;matches.item(-1)andmatches.item(matches.length)returnnull. The captured result remains static after a later matching node is appended.Change
Construct selector results as
NodeList<Element>rather thanElement[], and makeNodeListgeneric so the public and internal query APIs retain element item types. The accompanying type refinements keepchildNodes,children, and element collection helpers aligned with that collection shape.Tests
Adds runtime coverage for the returned
NodeListinstance, indexing, iteration,forEach(), in-range and out-of-rangeitem(), and static result behavior. Type assertions cover instance and standalone selector results asNodeList<Element>and.item()asElement | null.Stack
correct-selector-matchingValidation
Fresh GitHub CI on restacked head
e08f0afpasses: