Skip to content

Commit

Permalink
fix a small bug of enqueueUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Siubaak committed Apr 12, 2019
1 parent 5a34b8b commit 1598b63
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/hooks/effect.ts
Expand Up @@ -15,7 +15,7 @@ export default function useEffect(effect: Effect, guard: any[] = null) {
const prevGuard = instance.prevGuard

if (is.undefined(prevGuard)) {
throw new Error('unmatch any effects. please don\'t call useEffect in if/loop statement')
throw new Error('unmatch any effects, please don\'t call useEffect in if/loop statement')
}

let shouldCall = false
Expand Down
4 changes: 1 addition & 3 deletions src/instances/dom.ts
Expand Up @@ -79,9 +79,7 @@ export default class DOMInstance implements Instance {
}

emitter.on('loaded', () => {
if (this.node) {
this.node.removeAttribute(DATA_ID)
}
if (this.node) this.node.removeAttribute(DATA_ID)
})

return markup
Expand Down
4 changes: 1 addition & 3 deletions src/instances/text.ts
Expand Up @@ -27,9 +27,7 @@ export default class TextInstance implements Instance {
const wrapper = getNode(this.id)
if (wrapper) {
this.node = wrapper.firstChild as Text
if (!this.node) {
this.node = createNode('') as Text
}
if (!this.node) this.node = createNode('') as Text
wrapper.parentNode.insertBefore(this.node, wrapper)
wrapper.remove()
}
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/reconciler.ts
Expand Up @@ -57,7 +57,9 @@ class Reconciler {
}

enqueueUpdate(instance: Instance, element: Elem): void {
this.dirtyList.current.push({ instance, element })
if (this.dirtyList.current) {
this.dirtyList.current.push({ instance, element })
}
}

private runBatchUpdate() {
Expand Down

0 comments on commit 1598b63

Please sign in to comment.