Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[jsfm] Revert the destroy logic modification in #1529 (#1622)
Browse files Browse the repository at this point in the history
Revert the modification of the destroy logic in #1529 , it may cause breaking change when
executing `destroyInstance`.
  • Loading branch information
Hanks10100 committed Oct 9, 2018
1 parent 2813b54 commit 36d78cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 48 deletions.
24 changes: 3 additions & 21 deletions runtime/vdom/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,29 +200,11 @@ export default class Document {
debugLog(`[destroy](${this.id},document,${this.ref}) `
+ `Destroy document (id: "${this.id}", URL: "${this.URL}")`)
}

removeDoc(this.id)
delete this.id
delete this.URL
delete this.documentElement
delete this.ownerDocument
delete this.body

// remove listener and taskCenter
delete this.listener
this.taskCenter.destroyCallback()
delete this.taskCenter

// remove nodeMap
for (const id in this.nodeMap) {
try {
if (typeof this.nodeMap[id] !== 'undefined') {
this.nodeMap[id].destroy()
}
}
catch (e) {}
}
delete this.listener
delete this.nodeMap
delete this.taskCenter
removeDoc(this.id)
}
}

Expand Down
30 changes: 3 additions & 27 deletions runtime/vdom/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,10 @@ export default class Node {
const doc = getDoc(this.docId)
if (doc) {
delete this.docId
delete this.ownerDocument
delete doc.nodeMap[this.nodeId]
}

// node props
delete this.nodeId
delete this.ref
delete this.parentNode
delete this.nextSibling
delete this.previousSibling

// element props
delete this.nodeType
delete this.type
delete this.attr
delete this.style
delete this.classStyle
delete this.event
delete this.depth

// child nodes
try {
this.children.forEach(child => {
child.destroy()
})
}
catch (e) {}
delete this.children
delete this.pureChildren
this.children.forEach(child => {
child.destroy()
})
}
}

0 comments on commit 36d78cf

Please sign in to comment.