Skip to content

Commit 43ccd4c

Browse files
committed
add test case for removing transcluded directives
1 parent db12331 commit 43ccd4c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/unit/specs/compiler/compile_spec.js

+27
Original file line numberDiff line numberDiff line change
@@ -270,5 +270,32 @@ if (_.inBrowser) {
270270
expect(childSpy).toHaveBeenCalledWith(2)
271271
})
272272

273+
it('should remove transcluded directives from parent when unlinking', function (done) {
274+
var vm = new Vue({
275+
el: el,
276+
template:
277+
'<div v-if="ok">' +
278+
'<div v-component="test">{{test}}</div>' +
279+
'</div>',
280+
data: {
281+
test: 'parent',
282+
ok: true
283+
},
284+
components: {
285+
test: {
286+
template: '<content></content>'
287+
}
288+
}
289+
})
290+
expect(vm.$el.textContent).toBe('parent')
291+
expect(vm._directives.length).toBe(3)
292+
vm.ok = false
293+
_.nextTick(function () {
294+
expect(vm.$el.textContent).toBe('')
295+
expect(vm._directives.length).toBe(1)
296+
done()
297+
})
298+
})
299+
273300
})
274301
}

0 commit comments

Comments
 (0)