| 875 | } |
| 876 | |
| 877 | export 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 | |
| 916 | export function invokeVNodeHook( |
| 917 | hook: VNodeHook, |