1 | import { extend } from '../util';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export function isSameNodeType(node, vnode, hydrating) {
|
10 | if (typeof vnode==='string' || typeof vnode==='number') {
|
11 | return node.splitText!==undefined;
|
12 | }
|
13 | if (typeof vnode.nodeName==='string') {
|
14 | return !node._componentConstructor && isNamedNode(node, vnode.nodeName);
|
15 | }
|
16 | return hydrating || node._componentConstructor===vnode.nodeName;
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export function isNamedNode(node, nodeName) {
|
25 | return node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();
|
26 | }
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export function getNodeProps(vnode) {
|
37 | let props = extend({}, vnode.attributes);
|
38 | props.children = vnode.children;
|
39 |
|
40 | let defaultProps = vnode.nodeName.defaultProps;
|
41 | if (defaultProps!==undefined) {
|
42 | for (let i in defaultProps) {
|
43 | if (props[i]===undefined) {
|
44 | props[i] = defaultProps[i];
|
45 | }
|
46 | }
|
47 | }
|
48 |
|
49 | return props;
|
50 | }
|