Skip to content

Commit e08d6b9

Browse files
committed
fix unnecessary child watcher calls on parent re-render (fix #3453)
1 parent 1bc13f8 commit e08d6b9

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/core/instance/lifecycle.js

-5
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ export function lifecycleMixin (Vue: Class<Component>) {
151151
if (vm._watcher) {
152152
vm._watcher.update()
153153
}
154-
if (vm._watchers.length) {
155-
for (let i = 0; i < vm._watchers.length; i++) {
156-
vm._watchers[i].update(true /* shallow */)
157-
}
158-
}
159154
}
160155

161156
Vue.prototype.$destroy = function () {

test/unit/features/options/props.spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,28 @@ describe('Options props', () => {
349349
}).$mount()
350350
expect(console.error.calls.count()).toBe(0)
351351
})
352+
353+
// #3453
354+
it('should not fire watcher on object/array props when parent re-renders', done => {
355+
const spy = jasmine.createSpy()
356+
const vm = new Vue({
357+
data: {
358+
arr: []
359+
},
360+
template: '<test :prop="arr">hi</test>',
361+
components: {
362+
test: {
363+
props: ['prop'],
364+
watch: {
365+
prop: spy
366+
},
367+
template: '<div><slot></slot></div>'
368+
}
369+
}
370+
}).$mount()
371+
vm.$forceUpdate()
372+
waitForUpdate(() => {
373+
expect(spy).not.toHaveBeenCalled()
374+
}).then(done)
375+
})
352376
})

0 commit comments

Comments
 (0)