Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DOMElementFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export default function createDOMElementFilter(
printChildren(
Array.prototype.slice
.call(node.childNodes || node.children)
.filter(filterNode),
.filter(child => filterNode(child)),
config,
indentation + config.indent,
depth,
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/pretty-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ test('prettyDOM can include all elements with a custom filter', () => {
`)
})

test('prettyDOM calls filterNode with only the node argument', () => {
const {container} = renderIntoDocument(
'<body><p>Hello, Dave</p><span>Second</span></body>',
)

const filterNode = jest.fn(() => true)

prettyDOM(container, Number.POSITIVE_INFINITY, {filterNode})

expect(filterNode).toHaveBeenCalledWith(expect.any(Node))
filterNode.mock.calls.forEach(callArgs => {
expect(callArgs).toHaveLength(1)
expect(callArgs[0]).toBeInstanceOf(Node)
})
})

test('prettyDOM supports named custom elements', () => {
window.customElements.define(
'my-element-1',
Expand Down
Loading