diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
index 9260cfe7a83b6f204a835a92523c3d00e0f3487f..00e7dbfe705d0af113792d66977afea500b4e3b1 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
@@ -16,29 +16,29 @@ describe('codegen', () => {
it('generate directive', () => {
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"_i":0}})}`
)
})
it('generate v-for directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [_c('v-uni-view',{key:item['k0'],attrs:{"_i":("2-"+$30)}}),_c('v-uni-view',{key:item['k1'],attrs:{"_i":("3-"+$30)}})]})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [_c('div',{key:item['k0'],attrs:{"_i":("2-"+$30)}}),_c('div',{key:item['k1'],attrs:{"_i":("3-"+$30)}})]})],2)}`
)
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [(_$g(("2-"+$30),'i'))?_c('v-uni-label',{key:item['k0'],attrs:{"_i":("2-"+$30)}}):_e()]})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [(_$g(("2-"+$30),'i'))?_c('span',{key:item['k0'],attrs:{"_i":("2-"+$30)}}):_e()]})],2)}`
)
})
it('generate events with multiple statements', () => {
assertCodegen(
'A{{ d | e | f }}B{{text}}C
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_v("A"+(_$g(0,'t0'))+"B"+(_$g(0,'t1'))+"C")])}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_v("A"+(_$g(0,'t0'))+"B"+(_$g(0,'t1'))+"C")])}`
)
})
it('generate slot fallback content', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("default",[_c('v-uni-view',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])],{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",[_c('div',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])],{"_i":1})],2)}`
)
})
it('generate v-slot', () => {
@@ -60,14 +60,14 @@ describe('codegen', () => {
it('generate wxs props', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{wxsProps:{"change:prop":"pos"},attrs:{"change:prop":swipe.sizeReady,"prop":_$gc(0,'change:pos'),"_i":0},on:{"touchstart":function($event){$event = $handleWxsEvent($event);swipe.touchstart($event, $getComponentDescriptor())},"touchmove":function($event){$event = $handleWxsEvent($event);swipe.touchmove($event, $getComponentDescriptor())},"touchend":function($event){$event = $handleWxsEvent($event);swipe.touchend($event, $getComponentDescriptor())},"change":function($event){return $handleViewEvent($event)}}})}`
+ `with(this){return _c('p',{wxsProps:{"change:prop":"pos"},attrs:{"change:prop":swipe.sizeReady,"prop":_$gc(0,'change:pos'),"_i":0},on:{"touchstart":function($event){$event = $handleWxsEvent($event);swipe.touchstart($event, $getComponentDescriptor())},"touchmove":function($event){$event = $handleWxsEvent($event);swipe.touchmove($event, $getComponentDescriptor())},"touchend":function($event){$event = $handleWxsEvent($event);swipe.touchend($event, $getComponentDescriptor())},"change":function($event){return $handleViewEvent($event)}}})}`
)
})
// TODO 后续优化dataset
// it('generate dataset', () => {
// assertCodegen(
// '',
- // `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ // `with(this){return _c('div',{attrs:{"_i":0}})}`
// )
// })
it('generate dataset', () => {
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
index e5a068fe526d4929d6a9bfbfb66c67b897945867..a5a238df2e5dde3a2e27a0ee8c1e10c2fdf02964 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
@@ -15,140 +15,140 @@ describe('codegen', () => {
it('generate directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"_i":0}})}`
)
// extra
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"_i":0}})}`
)
})
it('generate filters', () => {
assertCodegen(
'{{ d | e | f }}
',
- `with(this){return _c('v-uni-view',{attrs:{"id":_$g(0,'a-id'),"_i":0}},[_v((_$g(0,'t0')))])}`
+ `with(this){return _c('div',{attrs:{"id":_$g(0,'a-id'),"_i":0}},[_v((_$g(0,'t0')))])}`
)
})
it('generate filters with no arguments', () => {
assertCodegen(
'{{ d | e() }}
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_v((_$g(0,'t0')))])}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_v((_$g(0,'t0')))])}`
)
})
it('generate v-for directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
// iterator syntax
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,i,$20,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,i,$20,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,key,index,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,key,index,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
// destructuring
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,$10,$20,$30){return _c('v-uni-view',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,$10,$20,$30){return _c('li',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,key,index,$30){return _c('v-uni-view',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,key,index,$30){return _c('li',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
// v-for with extra element
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_c('v-uni-view',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("2-"+$30)}})})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_c('p',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return _c('li',{key:item,attrs:{"_i":("2-"+$30)}})})],2)}`
)
})
it('generate v-if directive', () => {
assertCodegen(
'hello
',
- `with(this){return (_$g(0,'i'))?_c('v-uni-view',{attrs:{"_i":0}},[_v("hello")]):_e()}`
+ `with(this){return (_$g(0,'i'))?_c('p',{attrs:{"_i":0}},[_v("hello")]):_e()}`
)
})
it('generate v-else directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):_c('v-uni-view',{attrs:{"_i":2}},[_v("world")])],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):_c('p',{attrs:{"_i":2}},[_v("world")])],1)}`
)
})
it('generate v-else-if directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('v-uni-view',{attrs:{"_i":2}},[_v("world")]):_e()],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):_e()],1)}`
)
})
it('generate v-else-if with v-else directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('v-uni-view',{attrs:{"_i":2}},[_v("world")]):_c('v-uni-view',{attrs:{"_i":3}},[_v("bye")])],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):_c('p',{attrs:{"_i":3}},[_v("bye")])],1)}`
)
})
it('generate multi v-else-if with v-else directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('v-uni-view',{attrs:{"_i":2}},[_v("world")]):(3)?_c('v-uni-view',{attrs:{"_i":3}},[_v("elseif")]):_c('v-uni-view',{attrs:{"_i":4}},[_v("bye")])],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):(3)?_c('p',{attrs:{"_i":3}},[_v("elseif")]):_c('p',{attrs:{"_i":4}},[_v("bye")])],1)}`
)
})
it('generate ref', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{ref:"component1",attrs:{"_i":0}})}`
+ `with(this){return _c('p',{ref:"component1",attrs:{"_i":0}})}`
)
})
it('generate ref on v-for', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('v-uni-view',{key:item,ref:"component1",refInFor:true,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('ul',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('li',{key:item,ref:"component1",refInFor:true,attrs:{"_i":("1-"+$30)}})}),1)}`
)
})
it('generate v-bind directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',_b({attrs:{"_i":0}},'v-uni-view',_$g(0,'v-bind'),false))}`
+ `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),false))}`
)
})
it('generate v-bind with prop directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',_b({attrs:{"_i":0}},'v-uni-view',_$g(0,'v-bind'),true))}`
+ `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),true))}`
)
})
it('generate v-bind directive with sync modifier', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',_b({attrs:{"_i":0}},'v-uni-view',_$g(0,'v-bind'),false,true))}`
+ `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),false,true))}`
)
})
it('generate v-model directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function($$v){$handleVModelEvent(0,$$v)},expression:"test"}})}`
+ `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function(){},expression:"test"}})}`
)
})
it('generate multiline v-model directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function($$v){$handleVModelEvent(0,$$v)},expression:"\\n test \\n"}})}`
+ `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function(){},expression:"\\n test \\n"}})}`
)
})
@@ -162,35 +162,35 @@ describe('codegen', () => {
it('generate template tag', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[[_c('v-uni-view',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])]],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[[_c('p',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])]],2)}`
)
})
it('generate single slot', () => {
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("default",null,{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",null,{"_i":1})],2)}`
)
})
it('generate named slot', () => {
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}`
)
})
it('generate slot fallback content', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("default",[_c('v-uni-view',{attrs:{"_i":2}},[_v("hi")])],{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",[_c('div',{attrs:{"_i":2}},[_v("hi")])],{"_i":1})],2)}`
)
})
it('generate slot target', () => {
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{attrs:{"slot":"one","_i":0},slot:"one"},[_v("hello world")])}`
+ `with(this){return _c('p',{attrs:{"slot":"one","_i":0},slot:"one"},[_v("hello world")])}`
)
})
@@ -201,7 +201,7 @@ describe('codegen', () => {
)
assertCodegen(
'{{ bar }}
',
- `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function(bar, _svm, _si){return _c('v-uni-view',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
+ `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function(bar, _svm, _si){return _c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
)
})
@@ -212,7 +212,7 @@ describe('codegen', () => {
)
assertCodegen(
'{{ bar }}
',
- `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return _c('v-uni-view',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
+ `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return _c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
)
})
@@ -230,7 +230,7 @@ describe('codegen', () => {
)
assertCodegen(
'{{ bar }}
',
- `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return (_svm._$g(("1-"+_si),'i'))?_c('v-uni-view',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))]):_e()}}],null,true)})}`
+ `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return (_svm._$g(("1-"+_si),'i'))?_c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))]):_e()}}],null,true)})}`
)
})
@@ -245,26 +245,26 @@ describe('codegen', () => {
// static
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{staticClass:_$g(0,'sc'),attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{staticClass:_$g(0,'sc'),attrs:{"_i":0}},[_v("hello world")])}`
)
// dynamic
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{class:_$g(0,'c'),attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{class:_$g(0,'c'),attrs:{"_i":0}},[_v("hello world")])}`
)
})
it('generate style binding', () => {
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{style:(_$g(0,'s')),attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{style:(_$g(0,'s')),attrs:{"_i":0}},[_v("hello world")])}`
)
})
it('generate v-show directive', () => {
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{directives:[{name:"show",rawName:"v-show",value:(_$g(0,'v-show')),expression:"_$g(0,'v-show')"}],attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{directives:[{name:"show",rawName:"v-show",value:(_$g(0,'v-show')),expression:"_$g(0,'v-show')"}],attrs:{"_i":0}},[_v("hello world")])}`
)
})
@@ -277,7 +277,7 @@ describe('codegen', () => {
// non input
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"value":_$g(0,'a-value'),"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"value":_$g(0,'a-value'),"_i":0}})}`
)
})
@@ -558,7 +558,7 @@ describe('codegen', () => {
it('generate component', () => {
assertCodegen(
'hi
',
- `with(this){return _c('my-component',{attrs:{"_i":0},on:{"notify":function($event){return $handleViewEvent($event)}}},[_c('v-uni-view',{attrs:{"_i":1}},[_v("hi")])],1)}`
+ `with(this){return _c('my-component',{attrs:{"_i":0},on:{"notify":function($event){return $handleViewEvent($event)}}},[_c('div',{attrs:{"_i":1}},[_v("hi")])],1)}`
)
})
@@ -572,16 +572,16 @@ describe('codegen', () => {
it('generate is attribute', () => {
assertCodegen(
'',
- `with(this){return _c("component1",{tag:"v-uni-view",attrs:{"_i":0}})}`
+ `with(this){return _c("component1",{tag:"div",attrs:{"_i":0}})}`
)
assertCodegen(
'',
- `with(this){return _c(_$g(0,'is'),{tag:"v-uni-view",attrs:{"_i":0}})}`
+ `with(this){return _c(_$g(0,'is'),{tag:"div",attrs:{"_i":0}})}`
)
// maybe a component and normalize type should be 1
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_c("component1",{tag:"v-uni-view",attrs:{"_i":1}})],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_c("component1",{tag:"div",attrs:{"_i":1}})],1)}`
)
})
@@ -589,12 +589,12 @@ describe('codegen', () => {
// have "inline-template'"
assertCodegen(
'hello world
',
- `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('v-uni-view',{attrs:{"_i":1}},[_c('v-uni-label',{attrs:{"_i":2}},[_v("hello world")])],1)}},staticRenderFns:[]}})}`
+ `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('p',{attrs:{"_i":1}},[_c('span',{attrs:{"_i":2}},[_v("hello world")])],1)}},staticRenderFns:[]}})}`
)
// "have inline-template attrs, but not having exactly one child element
assertCodegen(
'
',
- `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('v-uni-view',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
+ `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('hr',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
)
assertCodegen(
'',
@@ -603,11 +603,11 @@ describe('codegen', () => {
// have "is" attribute
assertCodegen(
'',
- `with(this){return _c("myComponent",{tag:"v-uni-view",attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('v-uni-view',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
+ `with(this){return _c("myComponent",{tag:"div",attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('div',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
)
assertCodegen(
'',
- `with(this){return _c("myComponent",{tag:"v-uni-view",attrs:{"_i":0}})}`
+ `with(this){return _c("myComponent",{tag:"div",attrs:{"_i":0}})}`
)
// expect('Inline-template components must have exactly one child element.').toHaveBeenWarned()
// expect(console.error.calls.count()).toBe(3)
@@ -616,8 +616,8 @@ describe('codegen', () => {
it('generate static trees inside v-for', () => {
assertCodegen(
``,
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((10),function(i,$10,$20,$30){return _c('v-uni-view',{attrs:{"_i":("1-"+$30)}},[_c('v-uni-view',{attrs:{"_i":("2-"+$30)}},[_c('v-uni-label',{attrs:{"_i":("3-"+$30)}})],1)],1)}),1)}`
- // [`with(this){return _c('v-uni-view',{attrs:{"_i":("2-"+$i)}},[_c('v-uni-view',{attrs:{"_i":("3-"+$i)}})])}`]
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((10),function(i,$10,$20,$30){return _c('div',{attrs:{"_i":("1-"+$30)}},[_c('p',{attrs:{"_i":("2-"+$30)}},[_c('span',{attrs:{"_i":("3-"+$30)}})],1)],1)}),1)}`
+ // [`with(this){return _c('p',{attrs:{"_i":("2-"+$i)}},[_c('p',{attrs:{"_i":("3-"+$i)}})])}`]
)
})
@@ -625,7 +625,7 @@ describe('codegen', () => {
// normalize type: 2
assertCodegen(
'{{ item }}
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_c('child',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return [_v((_$g(("2-"+$30),'t0')))]})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_c('child',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return [_v((_$g(("2-"+$30),'t0')))]})],2)}`
)
})
@@ -634,7 +634,7 @@ describe('codegen', () => {
// comments: true
// }, baseOptions)
// const template = ''
- // const generatedCode = `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ // const generatedCode = `with(this){return _c('p',{attrs:{"_i":0}})}`
// const ast = parse(template, options)
// optimize(ast, options)
@@ -648,7 +648,7 @@ describe('codegen', () => {
// comments: true
// }, baseOptions)
// const template = ''
- // const generatedCode = `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ // const generatedCode = `with(this){return _c('p',{attrs:{"_i":0}})}`
// const ast = parse(template, options)
// optimize(ast, options)
@@ -660,11 +660,11 @@ describe('codegen', () => {
it('does not squash templates inside v-pre', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{pre:true,attrs:{"_i":0}},[[_c('v-uni-view',{pre:true,attrs:{"_i":2}},[_v("{{msg}}")])]],2)}`
+ `with(this){return _c('div',{pre:true,attrs:{"_i":0}},[[_c('p',{pre:true,attrs:{"_i":2}},[_v("{{msg}}")])]],2)}`
)
// const template = ''
// const generatedCode = `with(this){return _m(0)}`
- // // const renderFn = `with(this){return _c('v-uni-view',{pre:true},[_c('template',[_c('v-uni-view',[_v("{{msg}}")])])],2)}`
+ // // const renderFn = `with(this){return _c('p',{pre:true},[_c('template',[_c('p',[_v("{{msg}}")])])],2)}`
// const ast = parse(template, baseOptions)
// optimize(ast, baseOptions)
// const res = generate(ast, baseOptions)
@@ -678,14 +678,14 @@ describe('codegen', () => {
`with(this){return _c("div")}`
)
// const res = generate(null, baseOptions)
- // expect(res.render).toBe(`with(this){return _c("v-uni-view")}`)
+ // expect(res.render).toBe(`with(this){return _c("p")}`)
// expect(res.staticRenderFns).toEqual([])
})
it('not specified directives option', () => {
assertCodegen(
'hello world
',
- `with(this){return (_$g(0,'i'))?_c('v-uni-view',{attrs:{"_i":0}},[_v("hello world")]):_e()}`, {
+ `with(this){return (_$g(0,'i'))?_c('p',{attrs:{"_i":0}},[_v("hello world")]):_e()}`, {
// isReservedTag
}
)
@@ -695,7 +695,7 @@ describe('codegen', () => {
it('should compile single v-for component inside template', () => {
assertCodegen(
`
`,
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_l((1),function(i,$10,$20,$30){return _c('foo',{key:i,attrs:{"_i":("2-"+$30)}})}):_e()],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_l((1),function(i,$10,$20,$30){return _c('foo',{key:i,attrs:{"_i":("2-"+$30)}})}):_e()],2)}`
)
})
})
diff --git a/packages/uni-template-compiler/lib/app/view.js b/packages/uni-template-compiler/lib/app/view.js
index 1360374d8a25f3b9e7f1a435ac5c5c0b5bc4aca7..ab6fa4a0b55b3620da33a15cf163619a7a11adc8 100644
--- a/packages/uni-template-compiler/lib/app/view.js
+++ b/packages/uni-template-compiler/lib/app/view.js
@@ -209,11 +209,11 @@ function handleViewEvents (events) {
function genVModel (el, isScopedSlot) {
if (el.model) {
el.model.value = createGenVar(el.attrsMap[ID], isScopedSlot)('v-model', el.model.value)
- if (el.tag === 'v-uni-input' || el.tag === 'v-uni-textarea') {
- el.model.callback = `function($$v){$handleVModelEvent(${el.attrsMap[ID]},$$v)}`
- } else {
- el.model.callback = `function(){}`
- }
+ // if (el.tag === 'v-uni-input' || el.tag === 'v-uni-textarea') {
+ // el.model.callback = `function($$v){$handleVModelEvent(${el.attrsMap[ID]},$$v)}`
+ // } else {
+ el.model.callback = `function(){}`
+ // }
}
}