@@ -32,7 +32,7 @@ function assertCodegen (template, generatedCode, ...args) {
3232describe ( 'codegen' , ( ) => {
3333it ( 'generate directive' , ( ) => {
3434assertCodegen (
35- '<p v-custom1:arg1.modifier="value1" v-custom2><p>' ,
35+ '<p v-custom1:arg1.modifier="value1" v-custom2></ p>' ,
3636`with(this){return _h('p',{directives:[{name:"custom1",rawName:"v-custom1:arg1.modifier",value:(value1),expression:"value1",arg:"arg1",modifiers:{"modifier":true}},{name:"custom2",rawName:"v-custom2",arg:"arg1"}]})}`
3737)
3838} )
@@ -46,26 +46,26 @@ describe('codegen', () => {
4646
4747it ( 'generate v-for directive' , ( ) => {
4848assertCodegen (
49- '<li v-for="item in items" :key="item.uid"></li>' ,
50- `with(this){return _l((items),function(item){return _h('li',{key:item.uid})})}`
49+ '<div>< li v-for="item in items" :key="item.uid"></li></div >' ,
50+ `with(this){return_h('div',[ _l((items),function(item){return _h('li',{key:item.uid})})] )}`
5151)
5252// iterator syntax
5353assertCodegen (
54- '<li v-for="(item, i) in items"></li>' ,
55- `with(this){return _l((items),function(item,i){return _h('li')})}`
54+ '<div>< li v-for="(item, i) in items"></li></div >' ,
55+ `with(this){return_h('div',[ _l((items),function(item,i){return _h('li')})] )}`
5656)
5757assertCodegen (
58- '<li v-for="(item, key, index) in items"></li>' ,
59- `with(this){return _l((items),function(item,key,index){return _h('li')})}`
58+ '<div>< li v-for="(item, key, index) in items"></li></div >' ,
59+ `with(this){return_h('div',[ _l((items),function(item,key,index){return _h('li')})] )}`
6060)
6161// destructuring
6262assertCodegen (
63- '<li v-for="{ a, b } in items"></li>' ,
64- `with(this){return _l((items),function({ a, b }){return _h('li')})}`
63+ '<div>< li v-for="{ a, b } in items"></li></div >' ,
64+ `with(this){return_h('div',[ _l((items),function({ a, b }){return _h('li')})] )}`
6565)
6666assertCodegen (
67- '<li v-for="({ a, b }, key, index) in items"></li>' ,
68- `with(this){return _l((items),function({ a, b },key,index){return _h('li')})}`
67+ '<div>< li v-for="({ a, b }, key, index) in items"></li></div >' ,
68+ `with(this){return_h('div',[ _l((items),function({ a, b },key,index){return _h('li')})] )}`
6969)
7070} )
7171
@@ -127,29 +127,29 @@ describe('codegen', () => {
127127
128128it ( 'generate template tag' , ( ) => {
129129assertCodegen (
130- '<template><p>{{hello}}</p></template>' ,
131- `with(this){return[ _h('p',[_s(hello)])]}`
130+ '<div>< template><p>{{hello}}</p></template></div >' ,
131+ `with(this){return_h('div',[[ _h('p',[_s(hello)])]]) }`
132132)
133133} )
134134
135135it ( 'generate single slot' , ( ) => {
136136assertCodegen (
137- '<slot></slot>' ,
138- `with(this){return _t("default")}`
137+ '<div>< slot></slot></div >' ,
138+ `with(this){return_h('div',[ _t("default")] )}`
139139)
140140} )
141141
142142it ( 'generate named slot' , ( ) => {
143143assertCodegen (
144- '<slot name="one"></slot>' ,
145- `with(this){return _t("one")}`
144+ '<div>< slot name="one"></slot></div >' ,
145+ `with(this){return_h('div',[ _t("one")] )}`
146146)
147147} )
148148
149149it ( 'generate slot fallback content' , ( ) => {
150150assertCodegen (
151- '<slot><div>hi</div></slot>' ,
152- `with(this){return _t("default",[_h('div',["hi"])])}`
151+ '<div>< slot><div>hi</div></slot></div >' ,
152+ `with(this){return_h('div',[ _t("default",[_h('div',["hi"]) ])])}`
153153)
154154} )
155155
@@ -356,8 +356,8 @@ describe('codegen', () => {
356356
357357it ( 'generate multiple event handlers' , ( ) => {
358358assertCodegen (
359- '<input @input="curent++" @input="onInput">' ,
360- `with(this){return _h('input',{on:{"input":[function($event){curent++},onInput]}})}`
359+ '<input @input="curent++" @input.stop ="onInput">' ,
360+ `with(this){return _h('input',{on:{"input":[function($event){curent++},function($event){$event.stopPropagation(); onInput($event)} ]}})}`
361361)
362362} )
363363