diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
index 1d368026f283de10be24d6e7c37214b2d2f64bd4..95fad8a6548ad63bc638c9f398680b87d7669ca2 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
@@ -126,6 +126,14 @@ describe('codegen', () => {
assertCodegen(
'',
`with(this){return _c('view',{staticClass:_$s(0,'sc',"bbbb"),attrs:{"id":"aaa","_i":0}})}`
+ )
+ assertCodegen(
+ '',
+ `with(this){return _c('custom',{attrs:{"id":"id","_i":0}})}`
+ )
+ assertCodegen(
+ '',
+ `with(this){return _c('custom',{attrs:{"id":_$s(0,'a-id',id),"_i":0}})}`
)
})
// TODO 后续优化 dataset
@@ -139,6 +147,10 @@ describe('codegen', () => {
assertCodegen(
'',
`with(this){return _c('view',{attrs:{"data-b":_$s(0,'a-data-b',b),"_i":0}})}`
+ )
+ assertCodegen(
+ '',
+ `with(this){return _c('custom',{attrs:{"data-a":"1","data-b":_$s(0,'a-data-b',b),"_i":0}})}`
)
})
it('generate v-if directive', () => {
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 9adfc872dcbebbf6bcb0cbb841938fe36d4a0c5b..598a2dd79004dd1f8687ae49545abd1a8f55bf04 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
@@ -68,7 +68,19 @@ describe('codegen', () => {
'
',
`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)}}})}`
)
- })
+ })
+
+ it('generate staticClass and id', () => {
+ assertCodegen(
+ '',
+ `with(this){return _c('custom',{attrs:{"id":"id","_i":0}})}`
+ )
+ assertCodegen(
+ '',
+ `with(this){return _c('custom',{attrs:{"id":_$g(0,'a-id'),"_i":0}})}`
+ )
+ })
+
// TODO 后续优化dataset
// it('generate dataset', () => {
// assertCodegen(
@@ -80,6 +92,10 @@ describe('codegen', () => {
assertCodegen(
'',
`with(this){return _c('v-uni-view',{attrs:{"data-a":"1","data-b":_$g(0,'a-data-b'),"_i":0}})}`
+ )
+ assertCodegen(
+ '',
+ `with(this){return _c('custom',{attrs:{"data-a":"1","data-b":_$g(0,'a-data-b'),"_i":0}})}`
)
})
it('generate v-if directive', () => {
diff --git a/packages/uni-template-compiler/__tests__/demo.js b/packages/uni-template-compiler/__tests__/demo.js
index 0eecf9b90e403cae075d87a7da93f091b91cf819..c4d307be070479cb370c16a954b0828689400d61 100644
--- a/packages/uni-template-compiler/__tests__/demo.js
+++ b/packages/uni-template-compiler/__tests__/demo.js
@@ -19,20 +19,7 @@ const scopedPath = path.resolve(__dirname, '../../')
const compiler = require('../lib')
const res = compiler.compile(
`
-
-
- {{label}}
-
-
- {{label}}
-
-
- {{label}}
-
-
- {{label}}
-
-
+
`, {
miniprogram: true,
resourcePath: '/User/fxy/Documents/test.wxml',
@@ -45,9 +32,9 @@ const res = compiler.compile(
mp: {
platform: 'mp-weixin'
},
- filterModules: ['swipe']
- // service: true,
- // view: true
+ filterModules: ['swipe'],
+ service: true,
+ view: true
})
console.log(require('util').inspect(res, {