MCPcopy
hub / github.com/vuejs/core / mergeProps

Function mergeProps

packages/runtime-core/src/vnode.ts:877–914  ·  view source on GitHub ↗
(...args: (Data & VNodeProps)[])

Source from the content-addressed store, hash-verified

875}
876
877export function mergeProps(...args: (Data & VNodeProps)[]): Data {
878 const ret: Data = {}
879 for (let i = 0; i < args.length; i++) {
880 const toMerge = args[i]
881 for (const key in toMerge) {
882 if (key === 'class') {
883 if (ret.class !== toMerge.class) {
884 ret.class = normalizeClass([ret.class, toMerge.class])
885 }
886 } else if (key === 'style') {
887 ret.style = normalizeStyle([ret.style, toMerge.style])
888 } else if (isOn(key)) {
889 const existing = ret[key]
890 const incoming = toMerge[key]
891 if (
892 incoming &&
893 existing !== incoming &&
894 !(isArray(existing) && existing.includes(incoming))
895 ) {
896 ret[key] = existing
897 ? [].concat(existing as any, incoming as any)
898 : incoming
899 } else if (
900 incoming == null &&
901 existing == null &&
902 // mergeProps({ 'onUpdate:modelValue': undefined }) should not retain
903 // the model listener.
904 !isModelListener(key)
905 ) {
906 ret[key] = incoming
907 }
908 } else if (key !== '') {
909 ret[key] = toMerge[key]
910 }
911 }
912 }
913 return ret
914}
915
916export function invokeVNodeHook(
917 hook: VNodeHook,

Callers 8

legacyRenderSlotFunction · 0.90
vnode.spec.tsFile · 0.90
applySSRDirectivesFunction · 0.85
ssrRenderFunction · 0.85
ssrScopeId.spec.tsFile · 0.85
cloneVNodeFunction · 0.85
renderFunction · 0.85

Calls 4

normalizeClassFunction · 0.90
normalizeStyleFunction · 0.90
isOnFunction · 0.90
isModelListenerFunction · 0.90

Tested by 2

ssrRenderFunction · 0.68
renderFunction · 0.68