@@ -32,7 +32,7 @@ function assertCodegen (template, generatedCode, ...args) {
32
32
describe ( 'codegen' , ( ) => {
33
33
it ( 'generate directive' , ( ) => {
34
34
assertCodegen (
35
- '<p v-custom1:arg1.modifier="value1" v-custom2><p>' ,
35
+ '<p v-custom1:arg1.modifier="value1" v-custom2></ p>' ,
36
36
`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"}]})}`
37
37
)
38
38
} )
@@ -46,26 +46,26 @@ describe('codegen', () => {
46
46
47
47
it ( 'generate v-for directive' , ( ) => {
48
48
assertCodegen (
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})})] )}`
51
51
)
52
52
// iterator syntax
53
53
assertCodegen (
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')})] )}`
56
56
)
57
57
assertCodegen (
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')})] )}`
60
60
)
61
61
// destructuring
62
62
assertCodegen (
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')})] )}`
65
65
)
66
66
assertCodegen (
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')})] )}`
69
69
)
70
70
} )
71
71
@@ -127,29 +127,29 @@ describe('codegen', () => {
127
127
128
128
it ( 'generate template tag' , ( ) => {
129
129
assertCodegen (
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)])]]) }`
132
132
)
133
133
} )
134
134
135
135
it ( 'generate single slot' , ( ) => {
136
136
assertCodegen (
137
- '<slot></slot>' ,
138
- `with(this){return _t("default")}`
137
+ '<div>< slot></slot></div >' ,
138
+ `with(this){return _h('div',[ _t("default")] )}`
139
139
)
140
140
} )
141
141
142
142
it ( 'generate named slot' , ( ) => {
143
143
assertCodegen (
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")] )}`
146
146
)
147
147
} )
148
148
149
149
it ( 'generate slot fallback content' , ( ) => {
150
150
assertCodegen (
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"]) ])])}`
153
153
)
154
154
} )
155
155
@@ -356,8 +356,8 @@ describe('codegen', () => {
356
356
357
357
it ( 'generate multiple event handlers' , ( ) => {
358
358
assertCodegen (
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)} ]}})}`
361
361
)
362
362
} )
363
363
0 commit comments