Skip to content

Commit

Permalink
support HTMLElement
Browse files Browse the repository at this point in the history
  • Loading branch information
eliranhe committed Feb 23, 2021
1 parent 81419fc commit 2a27c3d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ const traverse = (obj: any, visit: Visitor, queueFactor: number) => {
while (!queue.isEmpty()) {
const next = queue.dequeue()
if (!visit(next.val, next.path)) {
if (typeof next.val === 'object' && next.val !== null) {
const keys = Object.keys(next.val)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
queue.enqueue({
path: [...next.path, key],
val: next.val[key]
})
if (typeof next.val === 'object') {
if (next.val !== null && !(next.val instanceof HTMLElement)) {
const keys = Object.keys(next.val)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
queue.enqueue({
path: [...next.path, key],
val: next.val[key]
})
}
}
} else if (Array.isArray(next.val)) {
for (let i = 0; i < next.val.length; i++) {
Expand Down

0 comments on commit 2a27c3d

Please sign in to comment.