Skip to content

Commit 7580098

Browse files
authored
fix: fix memory leak of detached DOM tree (#210)
1 parent 89d5bf0 commit 7580098

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/data.ts

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { noop, warn } from './util'
44

55
export function collectDataFromConstructor (vm: Vue, Component: VueClass<Vue>) {
66
// override _init to prevent to init as Vue instance
7+
const originalInit = Component.prototype._init
78
Component.prototype._init = function (this: Vue) {
89
// proxy to actual vm
910
const keys = Object.getOwnPropertyNames(vm)
@@ -29,6 +30,9 @@ export function collectDataFromConstructor (vm: Vue, Component: VueClass<Vue>) {
2930
// should be acquired class property values
3031
const data = new Component()
3132

33+
// restore original _init to avoid memory leak (#209)
34+
Component.prototype._init = originalInit
35+
3236
// create plain data object
3337
const plainData = {}
3438
Object.keys(data).forEach(key => {

0 commit comments

Comments
 (0)