File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
test/unit/features/directives Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,7 @@ export function createPatchFunction (backend) {
342342 vnode . key === oldVnode . key &&
343343 ( vnode . isCloned || vnode . isOnce ) ) {
344344 vnode . elm = oldVnode . elm
345+ vnode . child = oldVnode . child
345346 return
346347 }
347348 let i
Original file line number Diff line number Diff line change @@ -313,6 +313,28 @@ describe('Directive v-once', () => {
313313 expect ( vm . $el . textContent ) . toBe ( 'aabbcc' )
314314 expect ( `v-once can only be used inside v-for that is keyed.` ) . toHaveBeenWarned ( )
315315 } )
316+
317+ // #4288
318+ it ( 'should inherit child reference for v-once' , done => {
319+ const vm = new Vue ( {
320+ template : `<div>{{a}}<test v-if="ok" v-once></test></div>` ,
321+ data : {
322+ a : 0 ,
323+ ok : true
324+ } ,
325+ components : {
326+ test : {
327+ template : '<div>foo</div>'
328+ }
329+ }
330+ } ) . $mount ( )
331+ vm . a ++ // first update to force a patch
332+ waitForUpdate ( ( ) => {
333+ expect ( vm . $el . textContent ) . toBe ( '1foo' )
334+ } ) . then ( ( ) => {
335+ vm . ok = false // teardown component with v-once
336+ } ) . then ( done ) // should not throw
337+ } )
316338} )
317339
318340function expectTextContent ( vm , text ) {
You can’t perform that action at this time.
0 commit comments