Skip to content

fix(prettyDOM): call filterNode with node only - #1383

Open
xianjianlf2 wants to merge 1 commit into
testing-library:mainfrom
xianjianlf2:fix/pretty-dom-filternode-args-1360
Open

fix(prettyDOM): call filterNode with node only#1383
xianjianlf2 wants to merge 1 commit into
testing-library:mainfrom
xianjianlf2:fix/pretty-dom-filternode-args-1360

Conversation

@xianjianlf2

Copy link
Copy Markdown

What changed

Wrap the filterNode callback passed to Array.prototype.filter so prettyDOM invokes 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/typed filterNode(node) API and can break callbacks that validate their argument list.

Fixes #1360

Validation

  • npm test -- --runTestsByPath src/__tests__/pretty-dom.js --runInBand --watch=false

I also ran the pre-commit lint-staged path; formatting, lint, and related tests passed. The full local validate step is currently blocked in this checkout by @types/node/ffi.d.ts syntax errors from a Node/TypeScript version mismatch, before this PR's code is involved.

@codesandbox-ci

codesandbox-ci Bot commented Aug 1, 2026

Copy link
Copy Markdown

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 2daee5e:

Sandbox Source
react-testing-library-examples Configuration

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.

prettyDOM filterNode argument is called with more args than expected based on type

1 participant