提交 49caf73a 编写于 作者: fxy060608's avatar fxy060608

feat(v3): remove static attrs (service)

上级 e0385a20
......@@ -6226,7 +6226,7 @@ var serviceContext = (function () {
let todoNavigator = false;
function navigate(path, callback) {
function navigate (path, callback) {
{
if (todoNavigator) {
return console.error(`已存在待跳转页面${todoNavigator.path},请不要连续多次跳转页面`)
......@@ -6254,7 +6254,7 @@ var serviceContext = (function () {
}
}
function todoNavigate() {
function todoNavigate () {
if (!todoNavigator) {
return
}
......@@ -6268,7 +6268,7 @@ var serviceContext = (function () {
return navigate()
}
function navigateFinish() {
function navigateFinish () {
{
// 创建预加载
const preloadWebview = createPreloadWebview();
......@@ -6278,9 +6278,9 @@ var serviceContext = (function () {
if (todoNavigator.nvue) {
return todoNavigate()
}
preloadWebview.loaded ?
todoNavigator.navigate() :
registerWebviewReady(preloadWebview.id, todoNavigate);
preloadWebview.loaded
? todoNavigator.navigate()
: registerWebviewReady(preloadWebview.id, todoNavigate);
}
}
......@@ -8859,7 +8859,6 @@ var serviceContext = (function () {
'uni-page-refresh',
'uni-actionsheet',
'uni-modal',
'uni-picker',
'uni-toast',
'uni-resize-sensor',
......
......@@ -190,7 +190,7 @@ describe('codegen', () => {
it('generate slot target', () => {
assertCodegen(
'<p slot="one">hello world</p>',
`with(this){return _c('p',{attrs:{"slot":"one","_i":0},slot:"one"})}`
`with(this){return _c('p',{attrs:{"_i":0},slot:"one"})}`
)
})
......@@ -291,7 +291,7 @@ describe('codegen', () => {
it('generate static attrs', () => {
assertCodegen(
'<input name="field1">',
`with(this){return _c('input',{attrs:{"name":"field1","_i":0}})}`
`with(this){return _c('input',{attrs:{"_i":0}})}`
)
})
......@@ -558,14 +558,14 @@ describe('codegen', () => {
it('generate component', () => {
assertCodegen(
'<my-component name="mycomponent1" :msg="msg" @notify="onNotify"><div>hi</div></my-component>',
`with(this){return _c('my-component',{attrs:{"name":"mycomponent1","msg":msg,"_i":0},on:{"notify":onNotify}},[_c('div',{attrs:{"_i":1}})])}`
`with(this){return _c('my-component',{attrs:{"msg":msg,"_i":0},on:{"notify":onNotify}},[_c('div',{attrs:{"_i":1}})])}`
)
})
it('generate svg component with children', () => {
assertCodegen(
'<svg><my-comp><circle :r="10"></circle></my-comp></svg>',
`with(this){return _c('svg',{attrs:{"_i":0}},[_c('my-comp',{attrs:{"_i":1}},[_c('circle',{attrs:{"r":10,"_i":2}})])],1)}`
`with(this){return _c('svg',{attrs:{"_i":0}},[_c('my-comp',{attrs:{"_i":1}},[_c('circle',{attrs:{"_i":2}})])],1)}`
)
})
......
......@@ -2,15 +2,15 @@ const compiler = require('../lib')
const res = compiler.compile(
`
<view>
<page-head v-if="a" v-for="item in items" :title="title"></page-head>
<image src="aaaa" :a="b"/>
</view>
`, {
resourcePath: '/User/fxy/Documents/test.wxml',
mp: {
platform: 'app-plus'
},
// service: true
view: true
service: true
// view: true
})
console.log(require('util').inspect(res, {
colors: true,
......
......@@ -21,7 +21,6 @@ function genData (el) {
dynamicTexts,
directivesBinding
} = el
let extras = ''
if (directivesBinding) {
......@@ -265,12 +264,17 @@ function processText (el) {
}
}
function processAttrs (el) {
el.attrs = el.attrs.filter(attr => attr.name === ID || isVar(attr.value))
}
function postTransformNode (el) {
parseEvent(el)
removeStatic(el)
renameBinding(el)
processAttrs(el)
processText(el)
updateForEleId(el)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册