File tree 2 files changed +23
-0
lines changed
test/unit/features/directives
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) {
342
342
vnode . key === oldVnode . key &&
343
343
( vnode . isCloned || vnode . isOnce ) ) {
344
344
vnode . elm = oldVnode . elm
345
+ vnode . child = oldVnode . child
345
346
return
346
347
}
347
348
let i
Original file line number Diff line number Diff line change @@ -313,6 +313,28 @@ describe('Directive v-once', () => {
313
313
expect ( vm . $el . textContent ) . toBe ( 'aabbcc' )
314
314
expect ( `v-once can only be used inside v-for that is keyed.` ) . toHaveBeenWarned ( )
315
315
} )
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
+ } )
316
338
} )
317
339
318
340
function expectTextContent ( vm , text ) {
You can’t perform that action at this time.
0 commit comments