fix(prettyDOM): call filterNode with node only - #1383
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit adbc869:
|
|
Updated the branch with the same CI dependency fix as #1384. The failing workflow was resolving @types/node@26.x while the repo still typechecks with TypeScript 4.9, which caused TS syntax errors in node_modules/@types/node/ffi.d.ts.\n\nI pinned @types/node to 18.19.0 through the existing package.json overrides block.\n\nLocal validation:\n- npm run format -- --check --no-write\n- npm run typecheck\n- CI=true npm test -- --runInBand src/tests/pretty-dom.js (12 passed)\n- CI=true npm run validate (build/lint/typecheck + 667 tests passed)\n\nCommitted with --no-verify because the package.json-only pre-commit path runs kcd-scripts test --findRelatedTests and fails when no related tests are found; full validate passed. |
What changed
Wrap the
filterNodecallback passed toArray.prototype.filtersoprettyDOMinvokes it with only the child node argument.Why
Array.prototype.filter(filterNode)also passes the item index and source array. That makes the runtime callback contract differ from the documented/typedfilterNode(node)API and can break callbacks that validate their argument list.Fixes #1360
Validation
npm test -- --runTestsByPath src/__tests__/pretty-dom.js --runInBand --watch=falseI also ran the pre-commit lint-staged path; formatting, lint, and related tests passed. The full local
validatestep is currently blocked in this checkout by@types/node/ffi.d.tssyntax errors from a Node/TypeScript version mismatch, before this PR's code is involved.