فهرست منبع

fix: fix child forceUpdate regression

close #9396
Evan You 7 سال پیش
والد
کامیت
44a17ba2cd
2فایلهای تغییر یافته به همراه24 افزوده شده و 1 حذف شده
  1. 1 1
      src/core/vdom/helpers/normalize-scoped-slots.js
  2. 23 0
      test/unit/modules/vdom/patch/edge-cases.spec.js

+ 1 - 1
src/core/vdom/helpers/normalize-scoped-slots.js

@@ -26,7 +26,7 @@ export function normalizeScopedSlots (
     }
   }
   res._normalized = true
-  res.$stable = slots && slots.$stable
+  res.$stable = slots ? slots.$stable : true
   return res
 }
 

+ 23 - 0
test/unit/modules/vdom/patch/edge-cases.spec.js

@@ -410,4 +410,27 @@ describe('vdom patch: edge cases', () => {
     expect(vm.$el.textContent).toBe('FooBar')
     expect(inlineHookSpy.calls.count()).toBe(2)
   })
+
+  // regression #9396
+  it('should not force update child with no slot content', done => {
+    const Child = {
+      updated: jasmine.createSpy(),
+      template: `<div></div>`
+    }
+
+    const parent = new Vue({
+      template: `<div>{{ count }}<child/></div>`,
+      data: {
+        count: 0
+      },
+      components: { Child }
+    }).$mount()
+
+    expect(parent.$el.textContent).toBe(`0`)
+    parent.count++
+    waitForUpdate(() => {
+      expect(parent.$el.textContent).toBe(`1`)
+      expect(Child.updated).not.toHaveBeenCalled()
+    }).then(done)
+  })
 })