ant-design-vue/components/vc-tree-select/src/SelectNode.jsx

33 lines
877 B
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { TreeNode } from '../../vc-tree';
/**
* SelectNode wrapped the tree node.
* Let's use SelectNode instead of TreeNode
* since TreeNode is so confuse here.
*/
export default {
name: 'SelectNode',
2019-02-01 09:23:00 +00:00
functional: true,
isTreeNode: true,
props: TreeNode.props,
2019-01-12 03:33:27 +00:00
render(h, context) {
2019-08-07 13:56:30 +00:00
const { props, slots, listeners, data, scopedSlots } = context;
const $slots = slots() || {};
2019-01-12 03:33:27 +00:00
const children = $slots.default;
2019-08-07 13:56:30 +00:00
const slotsKey = Object.keys($slots);
const scopedSlotsTemp = {}; // for vue 2.5.x
slotsKey.forEach(name => {
scopedSlotsTemp[name] = () => $slots[name];
});
const treeNodeProps = {
2019-01-12 03:33:27 +00:00
...data,
on: { ...listeners, ...data.nativeOn },
props,
2019-08-07 13:56:30 +00:00
scopedSlots: {
...scopedSlotsTemp,
...scopedSlots,
},
2019-01-12 03:33:27 +00:00
};
2019-08-07 13:56:30 +00:00
return <TreeNode {...treeNodeProps}>{children}</TreeNode>;
},
2019-01-12 03:33:27 +00:00
};