Skip to content

Commit

Permalink
fix: fix guardReactiveProps in v-bind case
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhe141 committed Aug 23, 2024
1 parent 9de1d10 commit 5f988c2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,25 @@ function _createVNode(
)
}

function generateProps(props: Data & VNodeProps) {
const target: Data & VNodeProps = {}
for (const key in props) {
if (isProxy(props[key])) {
target[key] = extend({}, props[key])
} else {
target[key] = props[key]
}
}
return target
}

export function guardReactiveProps(
props: (Data & VNodeProps) | null,
): (Data & VNodeProps) | null {
if (!props) return null
return isProxy(props) || isInternalObject(props) ? extend({}, props) : props
return isProxy(props) || isInternalObject(props)
? extend({}, generateProps(props))
: props
}

export function cloneVNode<T, U>(
Expand Down

1 comment on commit 5f988c2

@runlong-yao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要不要加个 key === 'style',减少依赖收集

Please sign in to comment.