@@ -13,9 +13,9 @@ describe('create-element', () => {
1313 const vm = new Vue ( {
1414 data : { msg : 'hello world' }
1515 } )
16- const _h = bind ( createElement , vm )
16+ const h = bind ( createElement , vm )
1717 renderState . activeInstance = vm
18- const vnode = _h ( 'p' , { } )
18+ const vnode = h ( 'p' , { } )
1919 expect ( vnode . tag ) . toBe ( 'p' )
2020 expect ( vnode . data ) . toEqual ( { } )
2121 expect ( vnode . children ) . toBeUndefined ( )
@@ -34,9 +34,9 @@ describe('create-element', () => {
3434 }
3535 }
3636 } )
37- const _h = bind ( createElement , vm )
37+ const h = bind ( createElement , vm )
3838 renderState . activeInstance = vm
39- const vnode = _h ( 'my-component' , { props : { msg : vm . message } } )
39+ const vnode = h ( 'my-component' , { props : { msg : vm . message } } )
4040 expect ( vnode . tag ) . toMatch ( / v u e - c o m p o n e n t - [ 0 - 9 ] + / )
4141 expect ( vnode . componentOptions . propsData ) . toEqual ( { msg : vm . message } )
4242 expect ( vnode . children ) . toBeUndefined ( )
@@ -50,10 +50,10 @@ describe('create-element', () => {
5050 const vm = new Vue ( {
5151 data : { msg : 'hello world' }
5252 } )
53- const _h = bind ( createElement , vm )
53+ const h = bind ( createElement , vm )
5454 const tag = 'custom-tag'
5555 renderState . activeInstance = vm
56- const vnode = _h ( tag , { } )
56+ const vnode = h ( tag , { } )
5757 expect ( vnode . tag ) . toBe ( 'custom-tag' )
5858 expect ( vnode . data ) . toEqual ( { } )
5959 expect ( vnode . children ) . toBeUndefined ( )
@@ -69,19 +69,19 @@ describe('create-element', () => {
6969 const vm = new Vue ( {
7070 data : { msg : 'hello world' }
7171 } )
72- const _h = bind ( createElement , vm )
72+ const h = bind ( createElement , vm )
7373 renderState . activeInstance = vm
74- const vnode = _h ( null , { } )
74+ const vnode = h ( null , { } )
7575 expect ( vnode ) . toEqual ( emptyVNode ( ) )
7676 } )
7777
7878 it ( 'render vnode with not string tag using createElement' , ( ) => {
7979 const vm = new Vue ( {
8080 data : { msg : 'hello world' }
8181 } )
82- const _h = bind ( createElement , vm )
82+ const h = bind ( createElement , vm )
8383 renderState . activeInstance = vm
84- const vnode = _h ( Vue . extend ( { // Component class
84+ const vnode = h ( Vue . extend ( { // Component class
8585 props : [ 'msg' ]
8686 } ) , { props : { msg : vm . message } } )
8787 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', () => {
9797 const vm = new Vue ( {
9898 data : { msg : 'hello world' }
9999 } )
100- const _h = bind ( createElement , vm )
101- _h ( 'p' , { } )
100+ const h = bind ( createElement , vm )
101+ h ( 'p' , { } )
102102 expect ( 'createElement cannot be called outside of component' ) . toHaveBeenWarned ( )
103103 } )
104104
105105 it ( 'render vnode with createElement with children' , ( ) => {
106106 const vm = new Vue ( { } )
107- const _h = bind ( createElement , vm )
107+ const h = bind ( createElement , vm )
108108 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' ) ] )
110110 expect ( vnode . children [ 0 ] . tag ) . toBe ( 'br' )
111111 expect ( vnode . children [ 1 ] . text ) . toBe ( 'hello world' )
112112 expect ( vnode . children [ 2 ] . tag ) . toBe ( 'br' )
113113 } )
114114
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' , ( ) => {
116126 const vm = new Vue ( {
117127 data : { message : 'hello world' } ,
118128 components : {
@@ -121,12 +131,35 @@ describe('create-element', () => {
121131 }
122132 }
123133 } )
124- const _h = bind ( createElement , vm )
134+ const h = bind ( createElement , vm )
125135 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' ) ] )
127137 expect ( vnode . componentOptions . children [ 0 ] . tag ) . toBe ( 'br' )
128138 expect ( vnode . componentOptions . children [ 1 ] ) . toBe ( 'hello world' )
129139 expect ( vnode . componentOptions . children [ 2 ] . tag ) . toBe ( 'br' )
130140 expect ( 'A component\'s children should be a function' ) . toHaveBeenWarned ( )
131141 } )
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+ } )
132165} )
0 commit comments