File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed
test/unit/modules/vdom/patch Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -257,11 +257,10 @@ export function updateChildComponent (
257257 }
258258
259259 // update listeners
260- if ( listeners ) {
261- const oldListeners = vm . $options . _parentListeners
262- vm . $options . _parentListeners = listeners
263- updateComponentListeners ( vm , listeners , oldListeners )
264- }
260+ listeners = listeners || emptyObject
261+ const oldListeners = vm . $options . _parentListeners
262+ vm . $options . _parentListeners = listeners
263+ updateComponentListeners ( vm , listeners , oldListeners )
265264
266265 // resolve slots + force update if has children
267266 if ( hasChildren ) {
Original file line number Diff line number Diff line change @@ -301,4 +301,30 @@ describe('vdom patch: edge cases', () => {
301301 expect ( vm . $el . children [ 0 ] . style . color ) . toBe ( 'green' )
302302 } ) . then ( done )
303303 } )
304+
305+ // #7294
306+ it ( 'should cleanup component inline events on patch when no events are present' , done => {
307+ const log = jasmine . createSpy ( )
308+ const vm = new Vue ( {
309+ data : { ok : true } ,
310+ template : `
311+ <div>
312+ <foo v-if="ok" @custom="log"/>
313+ <foo v-else/>
314+ </div>
315+ ` ,
316+ components : {
317+ foo : {
318+ render ( ) { }
319+ }
320+ } ,
321+ methods : { log }
322+ } ) . $mount ( )
323+
324+ vm . ok = false
325+ waitForUpdate ( ( ) => {
326+ vm . $children [ 0 ] . $emit ( 'custom' )
327+ expect ( log ) . not . toHaveBeenCalled ( )
328+ } ) . then ( done )
329+ } )
304330} )
You can’t perform that action at this time.
0 commit comments