|
|
@@ -13,7 +13,11 @@ import {
|
|
|
setValue,
|
|
|
} from '../../src/dom/prop'
|
|
|
import { setStyle } from '../../src/dom/prop'
|
|
|
-import { VaporComponentInstance, createComponent } from '../../src/component'
|
|
|
+import {
|
|
|
+ VaporComponentInstance,
|
|
|
+ applyFallthroughProps,
|
|
|
+ createComponent,
|
|
|
+} from '../../src/component'
|
|
|
import { ref, setCurrentInstance, svgNS, xlinkNS } from '@vue/runtime-dom'
|
|
|
import { makeRender } from '../_utils'
|
|
|
import {
|
|
|
@@ -546,6 +550,37 @@ describe('patchProp', () => {
|
|
|
expect(el.getAttribute('bar')).toBe('val')
|
|
|
expect(el.getAttribute('foo')).toBeNull()
|
|
|
})
|
|
|
+
|
|
|
+ test('should skip unchanged primitive dynamic props', () => {
|
|
|
+ const el = document.createElement('div')
|
|
|
+ let directSetCount = 0
|
|
|
+ let fallthroughSetCount = 0
|
|
|
+
|
|
|
+ Object.defineProperty(el, 'foo', {
|
|
|
+ set() {
|
|
|
+ directSetCount++
|
|
|
+ },
|
|
|
+ })
|
|
|
+ Object.defineProperty(el, 'bar', {
|
|
|
+ set() {
|
|
|
+ fallthroughSetCount++
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ setDynamicProps(el, [{ ['.foo']: 'val' }])
|
|
|
+ setDynamicProps(el, [{ ['.foo']: 'val' }])
|
|
|
+ expect(directSetCount).toBe(1)
|
|
|
+
|
|
|
+ setDynamicProps(el, [{ ['.foo']: 'next' }])
|
|
|
+ expect(directSetCount).toBe(2)
|
|
|
+
|
|
|
+ applyFallthroughProps(el, { ['.bar']: 'fallthrough' })
|
|
|
+ applyFallthroughProps(el, { ['.bar']: 'fallthrough' })
|
|
|
+ expect(fallthroughSetCount).toBe(1)
|
|
|
+
|
|
|
+ applyFallthroughProps(el, { ['.bar']: 'next' })
|
|
|
+ expect(fallthroughSetCount).toBe(2)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('setText', () => {
|