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()
|
||||
})
|
||||
|
||||
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 spy = vi.fn()
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
PatchFlags,
|
||||
ShapeFlags,
|
||||
isModelListener,
|
||||
isObject,
|
||||
isOn,
|
||||
looseEqual,
|
||||
} from '@vue/shared'
|
||||
|
@ -405,7 +406,7 @@ export function shouldUpdateComponent(
|
|||
for (let i = 0; i < dynamicProps.length; i++) {
|
||||
const key = dynamicProps[i]
|
||||
if (
|
||||
!looseEqual(nextProps![key], prevProps![key]) &&
|
||||
hasPropValueChanged(nextProps!, prevProps!, key) &&
|
||||
!isEmitListener(emits, key)
|
||||
) {
|
||||
return true
|
||||
|
@ -447,7 +448,7 @@ function hasPropsChanged(
|
|||
for (let i = 0; i < nextKeys.length; i++) {
|
||||
const key = nextKeys[i]
|
||||
if (
|
||||
!looseEqual(nextProps[key], prevProps[key]) &&
|
||||
hasPropValueChanged(nextProps, prevProps, key) &&
|
||||
!isEmitListener(emitsOptions, key)
|
||||
) {
|
||||
return true
|
||||
|
@ -456,6 +457,19 @@ function hasPropsChanged(
|
|||
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(
|
||||
{ vnode, parent }: ComponentInternalInstance,
|
||||
el: typeof vnode.el, // HostNode
|
||||
|
|
Loading…
Reference in New Issue