mirror of https://github.com/vuejs/core.git
chore: update
This commit is contained in:
parent
52c120cf33
commit
93eafa2d2b
|
@ -476,7 +476,7 @@ describe('renderer: component', () => {
|
||||||
).toHaveBeenWarned()
|
).toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should not update child component without changes', async () => {
|
test('should not update child component if style is not changed', async () => {
|
||||||
const text = ref(0)
|
const text = ref(0)
|
||||||
const spy = vi.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
PatchFlags,
|
PatchFlags,
|
||||||
ShapeFlags,
|
ShapeFlags,
|
||||||
isModelListener,
|
isModelListener,
|
||||||
|
isObject,
|
||||||
isOn,
|
isOn,
|
||||||
looseEqual,
|
looseEqual,
|
||||||
} from '@vue/shared'
|
} from '@vue/shared'
|
||||||
|
@ -405,7 +406,7 @@ export function shouldUpdateComponent(
|
||||||
for (let i = 0; i < dynamicProps.length; i++) {
|
for (let i = 0; i < dynamicProps.length; i++) {
|
||||||
const key = dynamicProps[i]
|
const key = dynamicProps[i]
|
||||||
if (
|
if (
|
||||||
!looseEqual(nextProps![key], prevProps![key]) &&
|
hasPropValueChanged(nextProps!, prevProps!, key) &&
|
||||||
!isEmitListener(emits, key)
|
!isEmitListener(emits, key)
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
|
@ -447,7 +448,7 @@ function hasPropsChanged(
|
||||||
for (let i = 0; i < nextKeys.length; i++) {
|
for (let i = 0; i < nextKeys.length; i++) {
|
||||||
const key = nextKeys[i]
|
const key = nextKeys[i]
|
||||||
if (
|
if (
|
||||||
!looseEqual(nextProps[key], prevProps[key]) &&
|
hasPropValueChanged(nextProps, prevProps, key) &&
|
||||||
!isEmitListener(emitsOptions, key)
|
!isEmitListener(emitsOptions, key)
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
|
@ -456,6 +457,19 @@ function hasPropsChanged(
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasPropValueChanged(
|
||||||
|
nextProps: Data,
|
||||||
|
prevProps: Data,
|
||||||
|
key: string,
|
||||||
|
): boolean {
|
||||||
|
const nextProp = nextProps[key]
|
||||||
|
const prevProp = prevProps[key]
|
||||||
|
if (key === 'style' && isObject(nextProp) && isObject(prevProp)) {
|
||||||
|
return !looseEqual(nextProp, prevProp)
|
||||||
|
}
|
||||||
|
return nextProp !== prevProp
|
||||||
|
}
|
||||||
|
|
||||||
export function updateHOCHostEl(
|
export function updateHOCHostEl(
|
||||||
{ vnode, parent }: ComponentInternalInstance,
|
{ vnode, parent }: ComponentInternalInstance,
|
||||||
el: typeof vnode.el, // HostNode
|
el: typeof vnode.el, // HostNode
|
||||||
|
|
Loading…
Reference in New Issue