diff --git a/src/compiler.js b/src/compiler.js index cc7537066..09d3b08ec 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -78,6 +78,7 @@ function Compiler (vm, options) { // register child id on parent var childId = compiler.el.getAttribute(idAttr) if (childId && parent) { + compiler.childId = childId parent.vm.$[childId] = vm } @@ -590,9 +591,13 @@ CompilerProto.destroy = function () { } } // remove self from parentCompiler - var parent = compiler.parentCompiler + var parent = compiler.parentCompiler, + childId = compiler.childId if (parent) { parent.childCompilers.splice(parent.childCompilers.indexOf(compiler), 1) + if (childId) { + delete parent.vm.$[childId] + } } // remove el if (el === document.body) { diff --git a/test/functional/fixtures/child-id.html b/test/functional/fixtures/child-id.html deleted file mode 100644 index b8647f4ee..000000000 --- a/test/functional/fixtures/child-id.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -
-
- {{msg}} -
-
- - - \ No newline at end of file diff --git a/test/unit/specs/directives.js b/test/unit/specs/directives.js index cc23cd937..bca7a2dfa 100644 --- a/test/unit/specs/directives.js +++ b/test/unit/specs/directives.js @@ -566,6 +566,8 @@ describe('UNIT: Directives', function () { assert.ok(t.$.hihi instanceof Child) t.$.hihi.test() assert.ok(called) + t.$.hihi.$destroy() + assert.notOk('hihi' in t.$) }) })