File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ exports.$mount = function (el) {
1515 _ . warn ( '$mount() should be called only once.' )
1616 return
1717 }
18- if ( typeof el === 'string' ) {
18+ if ( ! el ) {
19+ el = document . createElement ( 'div' )
20+ } else if ( typeof el === 'string' ) {
1921 var selector = el
2022 el = document . querySelector ( el )
2123 if ( ! el ) {
Original file line number Diff line number Diff line change @@ -28,6 +28,19 @@ if (_.inBrowser) {
2828 expect ( el . textContent ) . toBe ( 'hi!' )
2929 } )
3030
31+ it ( 'auto-create' , function ( ) {
32+ var vm = new Vue ( {
33+ template : '{{a}}' ,
34+ data : {
35+ a : 123
36+ }
37+ } )
38+ vm . $mount ( )
39+ expect ( vm . $el ) . toBeTruthy ( )
40+ expect ( vm . $el . tagName ) . toBe ( 'DIV' )
41+ expect ( vm . $el . textContent ) . toBe ( '123' )
42+ } )
43+
3144 it ( 'selector' , function ( ) {
3245 el . id = 'mount-test'
3346 document . body . appendChild ( el )
You can’t perform that action at this time.
0 commit comments