ant-design-vue/components/_util/vnode.js
2020-06-10 18:21:16 +08:00

18 lines
452 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { filterEmpty } from './props-util';
import { cloneVNode } from 'vue';
export function cloneElement(n, nodeProps = {}, override = true) {
let ele = n;
if (Array.isArray(n)) {
ele = filterEmpty(n)[0];
}
if (!ele) {
return null;
}
const node = cloneVNode(ele, nodeProps);
// cloneVNode内部是合并属性这里改成覆盖属性
node.props = override ? { ...node.props, ...nodeProps } : node.props;
return node;
}