Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a0edc22

Browse files
lusarzeddyerburgh
authored andcommittedMar 10, 2018
refactor: simplify code of removeDuplicateNodes method (#461)
1 parent 3bbb2a9 commit a0edc22

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed
 

‎packages/test-utils/src/find-vnodes.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ function findAllVNodes (vnode: VNode, nodes: Array<VNode> = []): Array<VNode> {
2424
}
2525

2626
function removeDuplicateNodes (vNodes: Array<VNode>): Array<VNode> {
27-
const uniqueNodes = []
28-
vNodes.forEach((vNode) => {
29-
const exists = uniqueNodes.some(node => vNode.elm === node.elm)
30-
if (!exists) {
31-
uniqueNodes.push(vNode)
32-
}
33-
})
34-
return uniqueNodes
27+
return vNodes.filter((vNode, index) => index === vNodes.findIndex(node => vNode.elm === node.elm))
3528
}
3629

3730
function nodeMatchesRef (node: VNode, refName: string): boolean {

0 commit comments

Comments
 (0)
Please sign in to comment.