@@ -13,9 +13,9 @@ describe('create-element', () => {
13
13
const vm = new Vue ( {
14
14
data : { msg : 'hello world' }
15
15
} )
16
- const _h = bind ( createElement , vm )
16
+ const h = bind ( createElement , vm )
17
17
renderState . activeInstance = vm
18
- const vnode = _h ( 'p' , { } )
18
+ const vnode = h ( 'p' , { } )
19
19
expect ( vnode . tag ) . toBe ( 'p' )
20
20
expect ( vnode . data ) . toEqual ( { } )
21
21
expect ( vnode . children ) . toBeUndefined ( )
@@ -34,9 +34,9 @@ describe('create-element', () => {
34
34
}
35
35
}
36
36
} )
37
- const _h = bind ( createElement , vm )
37
+ const h = bind ( createElement , vm )
38
38
renderState . activeInstance = vm
39
- const vnode = _h ( 'my-component' , { props : { msg : vm . message } } )
39
+ const vnode = h ( 'my-component' , { props : { msg : vm . message } } )
40
40
expect ( vnode . tag ) . toMatch ( / v u e - c o m p o n e n t - [ 0 - 9 ] + / )
41
41
expect ( vnode . componentOptions . propsData ) . toEqual ( { msg : vm . message } )
42
42
expect ( vnode . children ) . toBeUndefined ( )
@@ -50,10 +50,10 @@ describe('create-element', () => {
50
50
const vm = new Vue ( {
51
51
data : { msg : 'hello world' }
52
52
} )
53
- const _h = bind ( createElement , vm )
53
+ const h = bind ( createElement , vm )
54
54
const tag = 'custom-tag'
55
55
renderState . activeInstance = vm
56
- const vnode = _h ( tag , { } )
56
+ const vnode = h ( tag , { } )
57
57
expect ( vnode . tag ) . toBe ( 'custom-tag' )
58
58
expect ( vnode . data ) . toEqual ( { } )
59
59
expect ( vnode . children ) . toBeUndefined ( )
@@ -69,19 +69,19 @@ describe('create-element', () => {
69
69
const vm = new Vue ( {
70
70
data : { msg : 'hello world' }
71
71
} )
72
- const _h = bind ( createElement , vm )
72
+ const h = bind ( createElement , vm )
73
73
renderState . activeInstance = vm
74
- const vnode = _h ( null , { } )
74
+ const vnode = h ( null , { } )
75
75
expect ( vnode ) . toEqual ( emptyVNode ( ) )
76
76
} )
77
77
78
78
it ( 'render vnode with not string tag using createElement' , ( ) => {
79
79
const vm = new Vue ( {
80
80
data : { msg : 'hello world' }
81
81
} )
82
- const _h = bind ( createElement , vm )
82
+ const h = bind ( createElement , vm )
83
83
renderState . activeInstance = vm
84
- const vnode = _h ( Vue . extend ( { // Component class
84
+ const vnode = h ( Vue . extend ( { // Component class
85
85
props : [ 'msg' ]
86
86
} ) , { props : { msg : vm . message } } )
87
87
expect ( vnode . tag ) . toMatch ( / v u e - c o m p o n e n t - [ 0 - 9 ] + / )
@@ -97,22 +97,32 @@ describe('create-element', () => {
97
97
const vm = new Vue ( {
98
98
data : { msg : 'hello world' }
99
99
} )
100
- const _h = bind ( createElement , vm )
101
- _h ( 'p' , { } )
100
+ const h = bind ( createElement , vm )
101
+ h ( 'p' , { } )
102
102
expect ( 'createElement cannot be called outside of component' ) . toHaveBeenWarned ( )
103
103
} )
104
104
105
105
it ( 'render vnode with createElement with children' , ( ) => {
106
106
const vm = new Vue ( { } )
107
- const _h = bind ( createElement , vm )
107
+ const h = bind ( createElement , vm )
108
108
renderState . activeInstance = vm
109
- const vnode = _h ( 'p' , void 0 , [ _h ( 'br' ) , 'hello world' , _h ( 'br' ) ] )
109
+ const vnode = h ( 'p' , void 0 , [ h ( 'br' ) , 'hello world' , h ( 'br' ) ] )
110
110
expect ( vnode . children [ 0 ] . tag ) . toBe ( 'br' )
111
111
expect ( vnode . children [ 1 ] . text ) . toBe ( 'hello world' )
112
112
expect ( vnode . children [ 2 ] . tag ) . toBe ( 'br' )
113
113
} )
114
114
115
- it ( 'warn message when use createElementWithChildren for component' , ( ) => {
115
+ it ( 'render vnode with children, omitting data' , ( ) => {
116
+ const vm = new Vue ( { } )
117
+ const h = bind ( createElement , vm )
118
+ renderState . activeInstance = vm
119
+ const vnode = h ( 'p' , [ h ( 'br' ) , 'hello world' , h ( 'br' ) ] )
120
+ expect ( vnode . children [ 0 ] . tag ) . toBe ( 'br' )
121
+ expect ( vnode . children [ 1 ] . text ) . toBe ( 'hello world' )
122
+ expect ( vnode . children [ 2 ] . tag ) . toBe ( 'br' )
123
+ } )
124
+
125
+ it ( 'warn message when using non-thunk children for component' , ( ) => {
116
126
const vm = new Vue ( {
117
127
data : { message : 'hello world' } ,
118
128
components : {
@@ -121,12 +131,35 @@ describe('create-element', () => {
121
131
}
122
132
}
123
133
} )
124
- const _h = bind ( createElement , vm )
134
+ const h = bind ( createElement , vm )
125
135
renderState . activeInstance = vm
126
- const vnode = _h ( 'my-component' , { props : { msg : vm . message } } , [ _h ( 'br' ) , 'hello world' , _h ( 'br' ) ] )
136
+ const vnode = h ( 'my-component' , { props : { msg : vm . message } } , [ h ( 'br' ) , 'hello world' , h ( 'br' ) ] )
127
137
expect ( vnode . componentOptions . children [ 0 ] . tag ) . toBe ( 'br' )
128
138
expect ( vnode . componentOptions . children [ 1 ] ) . toBe ( 'hello world' )
129
139
expect ( vnode . componentOptions . children [ 2 ] . tag ) . toBe ( 'br' )
130
140
expect ( 'A component\'s children should be a function' ) . toHaveBeenWarned ( )
131
141
} )
142
+
143
+ it ( 'render svg elements with correct namespace' , ( ) => {
144
+ const vm = new Vue ( { } )
145
+ const h = bind ( createElement , vm )
146
+ renderState . activeInstance = vm
147
+ const vnode = h ( 'svg' , [ h ( 'a' ) ] )
148
+ expect ( vnode . ns ) . toBe ( 'svg' )
149
+ // should apply ns to children
150
+ expect ( vnode . children [ 0 ] . ns ) . toBe ( 'svg' )
151
+ } )
152
+
153
+ it ( 'render MathML elements with correct namespace' , ( ) => {
154
+ const vm = new Vue ( { } )
155
+ const h = bind ( createElement , vm )
156
+ renderState . activeInstance = vm
157
+ const vnode = h ( 'math' , [ h ( 'matrix' ) ] )
158
+ expect ( vnode . ns ) . toBe ( 'math' )
159
+ // should apply ns to children
160
+ expect ( vnode . children [ 0 ] . ns ) . toBe ( 'math' )
161
+ // although not explicitly listed, elements nested under <math>
162
+ // should not be treated as component
163
+ expect ( vnode . children [ 0 ] . componentOptions ) . toBeUndefined ( )
164
+ } )
132
165
} )
0 commit comments