Simplify domFor logic
This commit is contained in:
parent
62b6308295
commit
9af9ea66a2
1 changed files with 10 additions and 17 deletions
|
|
@ -3,23 +3,16 @@
|
|||
var delayedRemoval = new WeakMap
|
||||
module.exports.delayedRemoval = delayedRemoval
|
||||
|
||||
module.exports.domFor = function *domFor(vnode, {generation} = {generation: undefined}) {
|
||||
let {dom, domSize} = vnode
|
||||
if (dom != null) {
|
||||
if (domSize == null) {
|
||||
if (delayedRemoval.get(dom) === generation) {
|
||||
yield dom
|
||||
}
|
||||
} else {
|
||||
let i = 0, next
|
||||
while (i < domSize) {
|
||||
next = dom.nextSibling
|
||||
if (delayedRemoval.get(dom) === generation) {
|
||||
yield dom
|
||||
i++
|
||||
}
|
||||
dom = next
|
||||
}
|
||||
module.exports.domFor = function *domFor({dom, domSize}, {generation} = {}) {
|
||||
if (dom != null) do {
|
||||
const {nextSibling} = dom
|
||||
|
||||
if (delayedRemoval.get(dom) === generation) {
|
||||
yield dom
|
||||
domSize--
|
||||
}
|
||||
|
||||
dom = nextSibling
|
||||
}
|
||||
while (domSize)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue