Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
yisar committed Dec 11, 2019
1 parent cbbab3b commit 90e9d5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"module": "dist/fre-esm.js",
"scripts": {
"test": "jest --coverage",
"test-key":"jest ./test/reconcilation.test.js",
"build": "rollup -c && gzip-size dist/fre.js",
"format": "prettier --write \"{src,test,demo}/**/*.js\""
},
Expand Down
6 changes: 3 additions & 3 deletions src/reconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function commit(fiber) {
let ref = fiber.ref
if (op === DELETE) {
fiber.hooks && fiber.hooks.list.forEach(e => e[2] && e[2]())
delRef(fiber.kids)
cleanupRef(fiber.kids)
while (fiber.tag === HOOK) fiber = fiber.child
parent.removeChild(fiber.node)
} else if (fiber.tag === HOOK) {
Expand Down Expand Up @@ -271,11 +271,11 @@ function refer(ref, dom) {
if (ref) isFn(ref) ? ref(dom) : (ref.current = dom)
}

function delRef(kids) {
function cleanupRef(kids) {
for (const k in kids) {
const kid = kids[k]
refer(kid.ref, null)
if (kid.kids) delRef(kid.kids)
if (kid.kids) cleanupRef(kid.kids)
}
}

Expand Down

0 comments on commit 90e9d5f

Please sign in to comment.