Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
f63216a6
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f63216a6
编写于
10月 23, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(mp): reduce bundle size
上级
f0cfbbc4
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
146 addition
and
130 deletion
+146
-130
packages/uni-mp-compiler/__tests__/class.spec.ts
packages/uni-mp-compiler/__tests__/class.spec.ts
+14
-14
packages/uni-mp-compiler/__tests__/codegen.spec.ts
packages/uni-mp-compiler/__tests__/codegen.spec.ts
+10
-10
packages/uni-mp-compiler/__tests__/component.spec.ts
packages/uni-mp-compiler/__tests__/component.spec.ts
+5
-5
packages/uni-mp-compiler/__tests__/ref.spec.ts
packages/uni-mp-compiler/__tests__/ref.spec.ts
+1
-1
packages/uni-mp-compiler/__tests__/scope.spec.ts
packages/uni-mp-compiler/__tests__/scope.spec.ts
+7
-7
packages/uni-mp-compiler/__tests__/scopeId.spec.ts
packages/uni-mp-compiler/__tests__/scopeId.spec.ts
+3
-3
packages/uni-mp-compiler/__tests__/style.spec.ts
packages/uni-mp-compiler/__tests__/style.spec.ts
+14
-14
packages/uni-mp-compiler/__tests__/test.spec.ts
packages/uni-mp-compiler/__tests__/test.spec.ts
+1
-1
packages/uni-mp-compiler/__tests__/vFor.spec.ts
packages/uni-mp-compiler/__tests__/vFor.spec.ts
+24
-24
packages/uni-mp-compiler/__tests__/vIf.spec.ts
packages/uni-mp-compiler/__tests__/vIf.spec.ts
+12
-12
packages/uni-mp-compiler/__tests__/vModel.spec.ts
packages/uni-mp-compiler/__tests__/vModel.spec.ts
+5
-5
packages/uni-mp-compiler/__tests__/vOn.mp.spec.ts
packages/uni-mp-compiler/__tests__/vOn.mp.spec.ts
+1
-1
packages/uni-mp-compiler/__tests__/vOn.spec.ts
packages/uni-mp-compiler/__tests__/vOn.spec.ts
+17
-17
packages/uni-mp-compiler/__tests__/vSlot.spec.ts
packages/uni-mp-compiler/__tests__/vSlot.spec.ts
+1
-1
packages/uni-mp-compiler/src/runtimeHelpers.ts
packages/uni-mp-compiler/src/runtimeHelpers.ts
+11
-5
packages/uni-mp-compiler/src/transform.ts
packages/uni-mp-compiler/src/transform.ts
+2
-2
packages/uni-mp-compiler/src/transforms/transformClass.ts
packages/uni-mp-compiler/src/transforms/transformClass.ts
+1
-1
packages/uni-mp-compiler/src/transforms/transformIdentifier.ts
...ges/uni-mp-compiler/src/transforms/transformIdentifier.ts
+1
-1
packages/uni-mp-compiler/src/transforms/vBind.ts
packages/uni-mp-compiler/src/transforms/vBind.ts
+1
-2
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+2
-2
packages/uni-mp-vue/src/index.ts
packages/uni-mp-vue/src/index.ts
+13
-2
未找到文件。
packages/uni-mp-compiler/__tests__/class.spec.ts
浏览文件 @
f63216a6
...
...
@@ -29,14 +29,14 @@ describe('compiler: transform class', () => {
`<view :class="foo"/>`
,
`<view class="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass
(_ctx.foo) }
return { a: _n(_ctx.foo) }
}`
)
assert
(
`<view :class="foo | bar"/>`
,
`<view class="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass
(_ctx.foo | _ctx.bar) }
return { a: _n(_ctx.foo | _ctx.bar) }
}`
)
})
...
...
@@ -45,14 +45,14 @@ describe('compiler: transform class', () => {
`<view :class="foo" class="bar"/>`
,
`<view class="{{[a, 'bar']}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass
(_ctx.foo) }
return { a: _n(_ctx.foo) }
}`
)
assert
(
`<view class="bar" :class="foo"/>`
,
`<view class="{{['bar', a]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass
(_ctx.foo) }
return { a: _n(_ctx.foo) }
}`
)
})
...
...
@@ -68,7 +68,7 @@ describe('compiler: transform class', () => {
`<view :class="{ a: 1, b: 0, c: true, d: false, e: null, f: undefined, g: ok, h: handle(ok), i: ok>1, j, [k]:1, [l]:m, ...n, ...{a:true}, ...{b:o} }"/>`
,
`<view class="{{['a', 'c', a && 'g', b && 'h', c && 'i', d && 'j', e, g && f, h, i, j]}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n
ormalizeClass(_ctx.n), i: _normalizeClass({ a: true }), j: _normalizeClass
({ b: _ctx.o }) }
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n
(_ctx.n), i: _n({ a: true }), j: _n
({ b: _ctx.o }) }
}`
)
})
...
...
@@ -91,14 +91,14 @@ describe('compiler: transform class', () => {
`<view :class="{ a: 1, b: 0, c: true, d: false, e: null, f: undefined, g: ok, h: handle(ok), i: ok>1, j, [k]:1, [l]:m, ...n, ...{a:true}, ...{b:o} }" class="foo bar"/>`
,
`<view class="{{['a', 'c', a && 'g', b && 'h', c && 'i', d && 'j', e, g && f, h, i, j, 'foo bar']}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n
ormalizeClass(_ctx.n), i: _normalizeClass({ a: true }), j: _normalizeClass
({ b: _ctx.o }) }
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n
(_ctx.n), i: _n({ a: true }), j: _n
({ b: _ctx.o }) }
}`
)
assert
(
`<view class="foo bar" :class="{ a: 1, b: 0, c: true, d: false, e: null, f: undefined, g: ok, h: handle(ok), i: ok>1, j, [k]:1, [l]:m, ...n, ...{a:true}, ...{b:o} }"/>`
,
`<view class="{{['foo bar', 'a', 'c', a && 'g', b && 'h', c && 'i', d && 'j', e, g && f, h, i, j]}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n
ormalizeClass(_ctx.n), i: _normalizeClass({ a: true }), j: _normalizeClass
({ b: _ctx.o }) }
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n
(_ctx.n), i: _n({ a: true }), j: _n
({ b: _ctx.o }) }
}`
)
})
...
...
@@ -107,21 +107,21 @@ describe('compiler: transform class', () => {
`<view :class="[classA,
\`\$
{classB}
\`
]"/>`
,
`<view class="{{[a, b]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass(_ctx.classA), b: _normalizeClass
(
\`\$
{_ctx.classB}
\`
) }
return { a: _n
(_ctx.classA), b: _n
(
\`\$
{_ctx.classB}
\`
) }
}`
)
assert
(
`<view :class="[classA, classB]"/>`
,
`<view class="{{[a, b]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass(_ctx.classA), b: _normalizeClass
(_ctx.classB) }
return { a: _n
(_ctx.classA), b: _n
(_ctx.classB) }
}`
)
assert
(
`<view :class="[classA, classB, { classC: isC, classD: isD }, 'classE', isF ? 'classF' : '', isG && 'classG', ...classH, ...[classI,classJ], handle(classK) ]"/>`
,
`<view class="{{[a, b, c, 'classE', d, e, f, g, h]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass(_ctx.classA), b: _normalizeClass(_ctx.classB), c: _normalizeClass({ classC: _ctx.isC, classD: _ctx.isD }), d: _normalizeClass(_ctx.isF ? 'classF' : ''), e: _normalizeClass(_ctx.isG && 'classG'), f: _normalizeClass(_ctx.classH), g: _normalizeClass([_ctx.classI, _ctx.classJ]), h: _normalizeClass
(_ctx.handle(_ctx.classK)) }
return { a: _n
(_ctx.classA), b: _n(_ctx.classB), c: _n({ classC: _ctx.isC, classD: _ctx.isD }), d: _n(_ctx.isF ? 'classF' : ''), e: _n(_ctx.isG && 'classG'), f: _n(_ctx.classH), g: _n([_ctx.classI, _ctx.classJ]), h: _n
(_ctx.handle(_ctx.classK)) }
}`
)
})
...
...
@@ -130,28 +130,28 @@ describe('compiler: transform class', () => {
`<view :class="[classA, classB]" class="foo bar"/>`
,
`<view class="{{[a, b, 'foo bar']}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass(_ctx.classA), b: _normalizeClass
(_ctx.classB) }
return { a: _n
(_ctx.classA), b: _n
(_ctx.classB) }
}`
)
assert
(
`<view class="foo bar" :class="[classA, classB]"/>`
,
`<view class="{{['foo bar', a, b]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass(_ctx.classA), b: _normalizeClass
(_ctx.classB) }
return { a: _n
(_ctx.classA), b: _n
(_ctx.classB) }
}`
)
assert
(
`<view :class="[classA, classB, { classC: isC, classD: isD }, 'classE', isF ? 'classF' : '', isG && 'classG', ...classH, ...[classI,classJ], handle(classK) ]" class="foo bar"/>`
,
`<view class="{{[a, b, c, 'classE', d, e, f, g, h, 'foo bar']}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass(_ctx.classA), b: _normalizeClass(_ctx.classB), c: _normalizeClass({ classC: _ctx.isC, classD: _ctx.isD }), d: _normalizeClass(_ctx.isF ? 'classF' : ''), e: _normalizeClass(_ctx.isG && 'classG'), f: _normalizeClass(_ctx.classH), g: _normalizeClass([_ctx.classI, _ctx.classJ]), h: _normalizeClass
(_ctx.handle(_ctx.classK)) }
return { a: _n
(_ctx.classA), b: _n(_ctx.classB), c: _n({ classC: _ctx.isC, classD: _ctx.isD }), d: _n(_ctx.isF ? 'classF' : ''), e: _n(_ctx.isG && 'classG'), f: _n(_ctx.classH), g: _n([_ctx.classI, _ctx.classJ]), h: _n
(_ctx.handle(_ctx.classK)) }
}`
)
assert
(
`<view class="foo bar" :class="[classA, classB, { classC: isC, classD: isD }, 'classE', isF ? 'classF' : '', isG && 'classG', ...classH, ...[classI,classJ], handle(classK) ]"/>`
,
`<view class="{{['foo bar', a, b, c, 'classE', d, e, f, g, h]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass(_ctx.classA), b: _normalizeClass(_ctx.classB), c: _normalizeClass({ classC: _ctx.isC, classD: _ctx.isD }), d: _normalizeClass(_ctx.isF ? 'classF' : ''), e: _normalizeClass(_ctx.isG && 'classG'), f: _normalizeClass(_ctx.classH), g: _normalizeClass([_ctx.classI, _ctx.classJ]), h: _normalizeClass
(_ctx.handle(_ctx.classK)) }
return { a: _n
(_ctx.classA), b: _n(_ctx.classB), c: _n({ classC: _ctx.isC, classD: _ctx.isD }), d: _n(_ctx.isF ? 'classF' : ''), e: _n(_ctx.isG && 'classG'), f: _n(_ctx.classH), g: _n([_ctx.classI, _ctx.classJ]), h: _n
(_ctx.handle(_ctx.classK)) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/codegen.spec.ts
浏览文件 @
f63216a6
...
...
@@ -5,10 +5,10 @@ describe('compiler: codegen', () => {
assert
(
`<view v-for="item in items" @click="onClick"></view>`
,
`<view wx:for="{{a}}" wx:for-item="item" bindtap="{{b}}"></view>`
,
`import {
vOn as _vOn, vFor as _vFor
} from "vue"
`import {
o as _o, f as _f
} from "vue"
export function render(_ctx, _cache) {
return { a: _
vFor(_ctx.items, (item, k0, i0) => { return {}; }), b: _vOn
(_ctx.onClick) }
return { a: _
f(_ctx.items, (item, k0, i0) => { return {}; }), b: _o
(_ctx.onClick) }
}`
,
{
inline
:
false
,
mode
:
'
module
'
,
prefixIdentifiers
:
false
}
)
...
...
@@ -18,10 +18,10 @@ export function render(_ctx, _cache) {
assert
(
`<view v-for="item in items" @click="onClick"></view>`
,
`<view wx:for="{{a}}" wx:for-item="item" bindtap="{{b}}"></view>`
,
`import {
vOn as _vOn, vFor as _vFor
} from "vue"
`import {
o as _o, f as _f
} from "vue"
export function render(_ctx, _cache) {
return { a: _
vFor(_ctx.items, (item, k0, i0) => { return {}; }), b: _vOn
(_ctx.onClick) }
return { a: _
f(_ctx.items, (item, k0, i0) => { return {}; }), b: _o
(_ctx.onClick) }
}`
,
{
inline
:
false
,
mode
:
'
module
'
}
)
...
...
@@ -35,9 +35,9 @@ export function render(_ctx, _cache) {
return function render(_ctx, _cache) {
with (_ctx) {
const {
vOn: _vOn, vFor: _vFor
} = _Vue
const {
o: _o, f: _f
} = _Vue
return { a: _
vFor(items, (item, k0, i0) => { return {}; }), b: _vOn
(onClick) }
return { a: _
f(items, (item, k0, i0) => { return {}; }), b: _o
(onClick) }
}
}`
,
{
inline
:
false
,
mode
:
'
function
'
,
prefixIdentifiers
:
false
}
...
...
@@ -47,10 +47,10 @@ return function render(_ctx, _cache) {
assert
(
`<view v-for="item in items" @click="onClick"></view>`
,
`<view wx:for="{{a}}" wx:for-item="item" bindtap="{{b}}"></view>`
,
`const {
vOn: _vOn, vFor: _vFor
} = Vue
`const {
o: _o, f: _f
} = Vue
return function render(_ctx, _cache) {
return { a: _
vFor(_ctx.items, (item, k0, i0) => { return {}; }), b: _vOn
(_ctx.onClick) }
return { a: _
f(_ctx.items, (item, k0, i0) => { return {}; }), b: _o
(_ctx.onClick) }
}`
,
{
inline
:
false
,
mode
:
'
function
'
}
)
...
...
@@ -69,7 +69,7 @@ return function render(_ctx, _cache) {
`{{hello}}`
,
`{{a}}`
,
`(_ctx, _cache) => {
return { a: _t
oDisplayString
(_ctx.hello) }
return { a: _t(_ctx.hello) }
}`
)
})
...
...
@@ -87,7 +87,7 @@ return function render(_ctx, _cache) {
`{{foo}}{{bar}}nested`
,
`{{a}}{{b}}nested`
,
`(_ctx, _cache) => {
return { a: _t
oDisplayString(_ctx.foo), b: _toDisplayString
(_ctx.bar) }
return { a: _t
(_ctx.foo), b: _t
(_ctx.bar) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/component.spec.ts
浏览文件 @
f63216a6
...
...
@@ -43,7 +43,7 @@ describe('compiler: transform component', () => {
`<custom v-for="item in items"/>`
,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) }
}`
,
{
nodeTransforms
:
[
addComponentBindLink
as
any
],
...
...
@@ -53,7 +53,7 @@ describe('compiler: transform component', () => {
`<custom v-for="(item,key,index) in items"/>`
,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, key, index) => { return { a: '2a9ec0b0-0' + '-' + index }; }) }
return { a: _
f
(_ctx.items, (item, key, index) => { return { a: '2a9ec0b0-0' + '-' + index }; }) }
}`
,
{
nodeTransforms
:
[
addComponentBindLink
as
any
],
...
...
@@ -65,7 +65,7 @@ describe('compiler: transform component', () => {
`<custom><custom1 v-for="item in items"/></custom>`
,
`<custom vue-slots="{{['default']}}" class="v-r" v-i="2a9ec0b0-0" bind:__l="__l"><custom1 wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/></custom>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-1' + '-' + i0 + ',' + '2a9ec0b0-0' }; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-1' + '-' + i0 + ',' + '2a9ec0b0-0' }; }) }
}`
,
{
nodeTransforms
:
[
addComponentBindLink
as
any
],
...
...
@@ -77,7 +77,7 @@ describe('compiler: transform component', () => {
`<custom v-for="item in items"><custom1/></custom>`
,
`<custom wx:for="{{a}}" wx:for-item="item" vue-slots="{{['default']}}" class="v-r-i-f" v-i="{{item.b}}" bind:__l="__l"><custom1 class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/></custom>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-1' + '-' + i0 + ',' + ('2a9ec0b0-0' + '-' + i0), b: '2a9ec0b0-0' + '-' + i0 }; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-1' + '-' + i0 + ',' + ('2a9ec0b0-0' + '-' + i0), b: '2a9ec0b0-0' + '-' + i0 }; }) }
}`
,
{
nodeTransforms
:
[
addComponentBindLink
as
any
],
...
...
@@ -89,7 +89,7 @@ describe('compiler: transform component', () => {
`<custom v-for="item in items"><custom1 v-for="item1 in item.items"/></custom>`
,
`<custom wx:for="{{a}}" wx:for-item="item" vue-slots="{{['default']}}" class="v-r-i-f" v-i="{{item.b}}" bind:__l="__l"><custom1 wx:for="{{item.a}}" wx:for-item="item1" class="v-r-i-f" v-i="{{item1.a}}" bind:__l="__l"/></custom>`
,
`(_ctx, _cache) => {
return { a: _
vFor(_ctx.items, (item, k0, i0) => { return { a: _vFor
(item.items, (item1, k1, i1) => { return { a: '2a9ec0b0-1' + '-' + i0 + '-' + i1 + ',' + ('2a9ec0b0-0' + '-' + i0) }; }), b: '2a9ec0b0-0' + '-' + i0 }; }) }
return { a: _
f(_ctx.items, (item, k0, i0) => { return { a: _f
(item.items, (item1, k1, i1) => { return { a: '2a9ec0b0-1' + '-' + i0 + '-' + i1 + ',' + ('2a9ec0b0-0' + '-' + i0) }; }), b: '2a9ec0b0-0' + '-' + i0 }; }) }
}`
,
{
nodeTransforms
:
[
addComponentBindLink
as
any
],
...
...
packages/uni-mp-compiler/__tests__/ref.spec.ts
浏览文件 @
f63216a6
...
...
@@ -22,7 +22,7 @@ describe('compiler: transform ref', () => {
`<custom v-for="item in items"/>`
,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/scope.spec.ts
浏览文件 @
f63216a6
...
...
@@ -6,7 +6,7 @@ describe('compiler: scope', () => {
`<view v-for="item in items" :key="item.id" :class="{red: item.isRed}" @longpress="longpress" @click="onClick(item)">{{item.title}}</view>`
,
`<view wx:for="{{a}}" wx:for-item="item" wx:key="b" class="{{[item.c && 'red']}}" bindlongpress="{{b}}" bindtap="{{item.d}}">{{item.a}}</view>`
,
`(_ctx, _cache) => {
return { a: _
vFor(_ctx.items, (item, k0, i0) => { return { a: _toDisplayString(item.title), b: item.id, c: item.isRed ? 1 : 0, d: _vOn($event => _ctx.onClick(item)) }; }), b: _vOn
(_ctx.longpress) }
return { a: _
f(_ctx.items, (item, k0, i0) => { return { a: _t(item.title), b: item.id, c: item.isRed ? 1 : 0, d: _o($event => _ctx.onClick(item)) }; }), b: _o
(_ctx.longpress) }
}`
)
})
...
...
@@ -15,21 +15,21 @@ describe('compiler: scope', () => {
`<view v-for="item in items" :key="item.id">{{item.title}}{{handle(foo)}}<view v-for="item1 in item.list" :key="item1.id" @click="onClick(item)" @longpress="longpress(item1)">{{item.id}}{{item1.title}}</view></view>`
,
`<view wx:for="{{a}}" wx:for-item="item" wx:key="e">{{item.a}}{{b}}<view wx:for="{{item.b}}" wx:for-item="item1" wx:key="b" bindtap="{{item.d}}" bindlongpress="{{item1.c}}">{{item.c}}{{item1.a}}</view></view>`
,
`(_ctx, _cache) => {
return { a: _
vFor(_ctx.items, (item, k0, i0) => { return { a: _toDisplayString(item.title), b: _vFor(item.list, (item1, k1, i1) => { return { a: _toDisplayString(item1.title), b: item1.id, c: _vOn($event => _ctx.longpress(item1)) }; }), c: _toDisplayString(item.id), d: _vOn($event => _ctx.onClick(item)), e: item.id }; }), b: _toDisplayString
(_ctx.handle(_ctx.foo)) }
return { a: _
f(_ctx.items, (item, k0, i0) => { return { a: _t(item.title), b: _f(item.list, (item1, k1, i1) => { return { a: _t(item1.title), b: item1.id, c: _o($event => _ctx.longpress(item1)) }; }), c: _t(item.id), d: _o($event => _ctx.onClick(item)), e: item.id }; }), b: _t
(_ctx.handle(_ctx.foo)) }
}`
)
assert
(
`<view v-for="item in items"><view v-for="item1 in item1" :data-id="item.id" :data-title="item1.title"/></view>`
,
`<view wx:for="{{a}}" wx:for-item="item"><view wx:for="{{b}}" wx:for-item="item1" data-id="{{item.a}}" data-title="{{item1.a}}"/></view>`
,
`(_ctx, _cache) => {
return { a: _
vFor(_ctx.items, (item, k0, i0) => { return { a: item.id }; }), b: _vFor
(_ctx.item1, (item1, k1, i1) => { return { a: item1.title }; }) }
return { a: _
f(_ctx.items, (item, k0, i0) => { return { a: item.id }; }), b: _f
(_ctx.item1, (item1, k1, i1) => { return { a: item1.title }; }) }
}`
)
assert
(
`<view v-for="(item,weekIndex) in weeks" :key="weekIndex" :data-id="item.id"><view v-for="(weeks,weeksIndex) in item" :key="weeksIndex" :data-id="weeks.id"/></view>`
,
`<view wx:for="{{a}}" wx:for-item="item" wx:key="b" data-id="{{item.c}}"><view wx:for="{{item.a}}" wx:for-item="weeks" wx:key="a" data-id="{{weeks.b}}"/></view>`
,
`(_ctx, _cache) => {
return { a: _
vFor(_ctx.weeks, (item, weekIndex, i0) => { return { a: _vFor
(item, (weeks, weeksIndex, i1) => { return { a: weeksIndex, b: weeks.id }; }), b: weekIndex, c: item.id }; }) }
return { a: _
f(_ctx.weeks, (item, weekIndex, i0) => { return { a: _f
(item, (weeks, weeksIndex, i1) => { return { a: weeksIndex, b: weeks.id }; }), b: weekIndex, c: item.id }; }) }
}`
)
})
...
...
@@ -38,7 +38,7 @@ describe('compiler: scope', () => {
`<view v-for="item in items"><view v-if="true" :data-id="id"></view></view>`
,
`<view wx:for="{{a}}" wx:for-item="item"><view wx:if="{{true}}" data-id="{{item.a}}"></view></view>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return true ? { a: _ctx.id } : {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return true ? { a: _ctx.id } : {}; }) }
}`
)
})
...
...
@@ -47,7 +47,7 @@ describe('compiler: scope', () => {
`<view v-if="ok">{{ok}}</view><view v-else-if="ok1">{{ok1}}</view><view v-else-if="ok2">{{ok2}}</view><view v-else>{{ok3}}</view>`
,
`<view wx:if="{{a}}">{{b}}</view><view wx:elif="{{c}}">{{d}}</view><view wx:elif="{{e}}">{{f}}</view><view wx:else>{{g}}</view>`
,
`(_ctx, _cache) => {
return _e
xtend({ a: _ctx.ok }, _ctx.ok ? { b: _toDisplayString(_ctx.ok) } : _ctx.ok1 ? { d: _toDisplayString(_ctx.ok1) } : _ctx.ok2 ? { f: _toDisplayString(_ctx.ok2) } : { g: _toDisplayString
(_ctx.ok3) }, { c: _ctx.ok1, e: _ctx.ok2 })
return _e
({ a: _ctx.ok }, _ctx.ok ? { b: _t(_ctx.ok) } : _ctx.ok1 ? { d: _t(_ctx.ok1) } : _ctx.ok2 ? { f: _t(_ctx.ok2) } : { g: _t
(_ctx.ok3) }, { c: _ctx.ok1, e: _ctx.ok2 })
}`
)
})
...
...
@@ -56,7 +56,7 @@ describe('compiler: scope', () => {
`<view v-if="ok"><view v-for="item in items" :key="item.id" :data-title="item.title" :data-foo="foo" @click="onClick"/></view><view v-else-if="ok1"><view v-for="item in items" :key="item.id" :data-title="item.title" :data-foo="foo" @click="onClick"/></view><view v-else><view v-for="item in items" :key="item.id" :data-title="item.title" :data-foo="foo" @click="onClick"/></view>`
,
`<view wx:if="{{a}}"><view wx:for="{{b}}" wx:for-item="item" wx:key="a" data-title="{{item.b}}" data-foo="{{c}}" bindtap="{{d}}"/></view><view wx:elif="{{e}}"><view wx:for="{{f}}" wx:for-item="item" wx:key="a" data-title="{{item.b}}" data-foo="{{g}}" bindtap="{{h}}"/></view><view wx:else><view wx:for="{{i}}" wx:for-item="item" wx:key="a" data-title="{{item.b}}" data-foo="{{j}}" bindtap="{{k}}"/></view>`
,
`(_ctx, _cache) => {
return _e
xtend({ a: _ctx.ok }, _ctx.ok ? { b: _vFor(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), c: _ctx.foo, d: _vOn(_ctx.onClick) } : _ctx.ok1 ? { f: _vFor(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), g: _ctx.foo, h: _vOn(_ctx.onClick) } : { i: _vFor(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), j: _ctx.foo, k: _vOn
(_ctx.onClick) }, { e: _ctx.ok1 })
return _e
({ a: _ctx.ok }, _ctx.ok ? { b: _f(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), c: _ctx.foo, d: _o(_ctx.onClick) } : _ctx.ok1 ? { f: _f(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), g: _ctx.foo, h: _o(_ctx.onClick) } : { i: _f(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), j: _ctx.foo, k: _o
(_ctx.onClick) }, { e: _ctx.ok1 })
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/scopeId.spec.ts
浏览文件 @
f63216a6
...
...
@@ -17,7 +17,7 @@ describe('compiler: transform scopeId', () => {
`<view :class="foo"/>`
,
`<view class="{{['data-v-5584ec96', a]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass
(_ctx.foo) }
return { a: _n(_ctx.foo) }
}`
,
options
)
...
...
@@ -35,7 +35,7 @@ describe('compiler: transform scopeId', () => {
`<view class="bar" :class="foo"/>`
,
`<view class="{{['bar data-v-5584ec96', a]}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass
(_ctx.foo) }
return { a: _n(_ctx.foo) }
}`
,
options
)
...
...
@@ -43,7 +43,7 @@ describe('compiler: transform scopeId', () => {
`<view :class="foo" class="bar"/>`
,
`<view class="{{[a, 'bar data-v-5584ec96']}}"/>`
,
`(_ctx, _cache) => {
return { a: _n
ormalizeClass
(_ctx.foo) }
return { a: _n(_ctx.foo) }
}`
,
options
)
...
...
packages/uni-mp-compiler/__tests__/style.spec.ts
浏览文件 @
f63216a6
...
...
@@ -22,14 +22,14 @@ describe('compiler: transform style', () => {
`<view :style="foo"/>`
,
`<view style="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle
(_ctx.foo) }
return { a: _s(_ctx.foo) }
}`
)
assert
(
`<view :style="foo | bar"/>`
,
`<view style="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle
(_ctx.foo | _ctx.bar) }
return { a: _s(_ctx.foo | _ctx.bar) }
}`
)
})
...
...
@@ -38,14 +38,14 @@ describe('compiler: transform style', () => {
`<view :style="foo" style="color:green;"/>`
,
`<view style="{{a + ';' + 'color:green;'}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle
(_ctx.foo) }
return { a: _s(_ctx.foo) }
}`
)
assert
(
`<view style="color:green;" :style="foo"/>`
,
`<view style="{{'color:green;' + ';' + a}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle
(_ctx.foo) }
return { a: _s(_ctx.foo) }
}`
)
})
...
...
@@ -70,7 +70,7 @@ describe('compiler: transform style', () => {
`<view :style="{color:'green',fontSize:'15px',backgroundColor: handle(bg),fontWeight,[padding]:box.padding,...style,...{margin:'0px'}}"/>`
,
`<view style="{{'color:' + 'green' + ';' + ('font-size:' + '15px') + ';' + ('background-color:' + a) + ';' + ('font-weight:' + b) + ';' + (c + ':' + d) + ';' + e + ';' + f}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.handle(_ctx.bg), b: _ctx.fontWeight, c: _h
yphenate(_ctx.padding), d: _ctx.box.padding, e: _stringifyStyle(_ctx.style), f: _stringifyStyle
({ margin: '0px' }) }
return { a: _ctx.handle(_ctx.bg), b: _ctx.fontWeight, c: _h
(_ctx.padding), d: _ctx.box.padding, e: _s(_ctx.style), f: _s
({ margin: '0px' }) }
}`
)
})
...
...
@@ -93,14 +93,14 @@ describe('compiler: transform style', () => {
`<view :style="{color:'green',fontSize:'15px',backgroundColor: handle(bg),fontWeight,[padding]:box.padding,...style,...{margin:'0px'}}" style="font-size:15px"/>`
,
`<view style="{{'color:' + 'green' + ';' + ('font-size:' + '15px') + ';' + ('background-color:' + a) + ';' + ('font-weight:' + b) + ';' + (c + ':' + d) + ';' + e + ';' + f + ';' + 'font-size:15px'}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.handle(_ctx.bg), b: _ctx.fontWeight, c: _h
yphenate(_ctx.padding), d: _ctx.box.padding, e: _stringifyStyle(_ctx.style), f: _stringifyStyle
({ margin: '0px' }) }
return { a: _ctx.handle(_ctx.bg), b: _ctx.fontWeight, c: _h
(_ctx.padding), d: _ctx.box.padding, e: _s(_ctx.style), f: _s
({ margin: '0px' }) }
}`
)
assert
(
`<view style="font-size:15px" :style="{color:'green',fontSize:'15px',backgroundColor: handle(bg),fontWeight,[padding]:box.padding,...style,...{margin:'0px'}}"/>`
,
`<view style="{{'font-size:15px' + ';' + ('color:' + 'green' + ';' + ('font-size:' + '15px') + ';' + ('background-color:' + a) + ';' + ('font-weight:' + b) + ';' + (c + ':' + d) + ';' + e + ';' + f)}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.handle(_ctx.bg), b: _ctx.fontWeight, c: _h
yphenate(_ctx.padding), d: _ctx.box.padding, e: _stringifyStyle(_ctx.style), f: _stringifyStyle
({ margin: '0px' }) }
return { a: _ctx.handle(_ctx.bg), b: _ctx.fontWeight, c: _h
(_ctx.padding), d: _ctx.box.padding, e: _s(_ctx.style), f: _s
({ margin: '0px' }) }
}`
)
})
...
...
@@ -109,21 +109,21 @@ describe('compiler: transform style', () => {
`<view :style="[styleA,
\`\$
{styleB}
\`
]"/>`
,
`<view style="{{a + ';' + b}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle(_ctx.styleA), b: _stringifyStyle
(
\`\$
{_ctx.styleB}
\`
) }
return { a: _s
(_ctx.styleA), b: _s
(
\`\$
{_ctx.styleB}
\`
) }
}`
)
assert
(
`<view :style="[styleA, styleB]"/>`
,
`<view style="{{a + ';' + b}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle(_ctx.styleA), b: _stringifyStyle
(_ctx.styleB) }
return { a: _s
(_ctx.styleA), b: _s
(_ctx.styleB) }
}`
)
assert
(
`<view :style="[styleA, styleB, { color:'red',fontSize }, 'font-weight:bold', ...styleC, ...[styleD,styleE], handle(styleF) ]"/>`
,
`<view style="{{a + ';' + b + ';' + c + ';' + 'font-weight:bold' + ';' + d + ';' + e + ';' + f}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle(_ctx.styleA), b: _stringifyStyle(_ctx.styleB), c: _stringifyStyle({ color: 'red', fontSize: _ctx.fontSize }), d: _stringifyStyle(_ctx.styleC), e: _stringifyStyle([_ctx.styleD, _ctx.styleE]), f: _stringifyStyle
(_ctx.handle(_ctx.styleF)) }
return { a: _s
(_ctx.styleA), b: _s(_ctx.styleB), c: _s({ color: 'red', fontSize: _ctx.fontSize }), d: _s(_ctx.styleC), e: _s([_ctx.styleD, _ctx.styleE]), f: _s
(_ctx.handle(_ctx.styleF)) }
}`
)
})
...
...
@@ -132,28 +132,28 @@ describe('compiler: transform style', () => {
`<view :style="[styleA, styleB]" style="font-size:15px"/>`
,
`<view style="{{a + ';' + b + ';' + 'font-size:15px'}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle(_ctx.styleA), b: _stringifyStyle
(_ctx.styleB) }
return { a: _s
(_ctx.styleA), b: _s
(_ctx.styleB) }
}`
)
assert
(
`<view style="font-size:15px" :style="[styleA, styleB]"/>`
,
`<view style="{{'font-size:15px' + ';' + (a + ';' + b)}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle(_ctx.styleA), b: _stringifyStyle
(_ctx.styleB) }
return { a: _s
(_ctx.styleA), b: _s
(_ctx.styleB) }
}`
)
assert
(
`<view :style="[styleA, styleB, { color:'red',fontSize }, 'font-weight:bold', ...styleC, ...[styleD,styleE], handle(styleF) ]" style="font-size:15px"/>`
,
`<view style="{{a + ';' + b + ';' + c + ';' + 'font-weight:bold' + ';' + d + ';' + e + ';' + f + ';' + 'font-size:15px'}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle(_ctx.styleA), b: _stringifyStyle(_ctx.styleB), c: _stringifyStyle({ color: 'red', fontSize: _ctx.fontSize }), d: _stringifyStyle(_ctx.styleC), e: _stringifyStyle([_ctx.styleD, _ctx.styleE]), f: _stringifyStyle
(_ctx.handle(_ctx.styleF)) }
return { a: _s
(_ctx.styleA), b: _s(_ctx.styleB), c: _s({ color: 'red', fontSize: _ctx.fontSize }), d: _s(_ctx.styleC), e: _s([_ctx.styleD, _ctx.styleE]), f: _s
(_ctx.handle(_ctx.styleF)) }
}`
)
assert
(
`<view style="font-size:15px" :style="[styleA, styleB, { color:'red',fontSize }, 'font-weight:bold', ...styleC, ...[styleD,styleE], handle(styleF) ]"/>`
,
`<view style="{{'font-size:15px' + ';' + (a + ';' + b + ';' + c + ';' + 'font-weight:bold' + ';' + d + ';' + e + ';' + f)}}"/>`
,
`(_ctx, _cache) => {
return { a: _s
tringifyStyle(_ctx.styleA), b: _stringifyStyle(_ctx.styleB), c: _stringifyStyle({ color: 'red', fontSize: _ctx.fontSize }), d: _stringifyStyle(_ctx.styleC), e: _stringifyStyle([_ctx.styleD, _ctx.styleE]), f: _stringifyStyle
(_ctx.handle(_ctx.styleF)) }
return { a: _s
(_ctx.styleA), b: _s(_ctx.styleB), c: _s({ color: 'red', fontSize: _ctx.fontSize }), d: _s(_ctx.styleC), e: _s([_ctx.styleD, _ctx.styleE]), f: _s
(_ctx.handle(_ctx.styleF)) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/test.spec.ts
浏览文件 @
f63216a6
...
...
@@ -40,7 +40,7 @@ describe('compiler', () => {
`<view v-for="item in items"><view v-if="ok"></view></view>`
,
`<view wx:if="{{a}}">{{b}}</view>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return _ctx.ok ? {} : {}; }), b: _ctx.ok }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return _ctx.ok ? {} : {}; }), b: _ctx.ok }
}`
,
{
renderDataSpread
:
false
,
...
...
packages/uni-mp-compiler/__tests__/vFor.spec.ts
浏览文件 @
f63216a6
...
...
@@ -29,7 +29,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="index in 5" />`
,
`<view wx:for="{{a}}" wx:for-item="index"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(5, (index, k0, i0) => { return {}; }) }
return { a: _
f
(5, (index, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -38,7 +38,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="(item) in items" />`
,
`<view wx:for="{{a}}" wx:for-item="item"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -47,7 +47,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="({ id, value }) in items" />`
,
`<view wx:for="{{a}}" wx:for-item="v0"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, ({ id, value }, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, ({ id, value }, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -56,7 +56,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="([ id, value ]) in items" />`
,
`<view wx:for="{{a}}" wx:for-item="v0"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, ([id, value], k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, ([id, value], k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -65,7 +65,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="(item, key) in items" />`
,
`<view wx:for="{{a}}" wx:for-item="item"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, key, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, key, i0) => { return {}; }) }
}`
)
})
...
...
@@ -74,7 +74,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="(item, key, index) in items" />`
,
`<view wx:for="{{a}}" wx:for-item="item"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, key, index) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, key, index) => { return {}; }) }
}`
)
})
...
...
@@ -83,7 +83,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="(value,,index) in items" />`
,
`<view wx:for="{{a}}" wx:for-item="value"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (value, k0, index) => { return {}; }) }
return { a: _
f
(_ctx.items, (value, k0, index) => { return {}; }) }
}`
)
})
...
...
@@ -92,7 +92,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="(,,index) in items" />`
,
`<view wx:for="{{a}}" wx:for-item="v0"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (v0, k0, index) => { return {}; }) }
return { a: _
f
(_ctx.items, (v0, k0, index) => { return {}; }) }
}`
)
})
...
...
@@ -101,7 +101,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="item in items" />`
,
`<view wx:for="{{a}}" wx:for-item="item"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -110,7 +110,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="item, key in items" />`
,
`<view wx:for="{{a}}" wx:for-item="item"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, key, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, key, i0) => { return {}; }) }
}`
)
})
...
...
@@ -119,7 +119,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="value, key, index in items" />`
,
`<view wx:for="{{a}}" wx:for-item="value"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (value, key, index) => { return {}; }) }
return { a: _
f
(_ctx.items, (value, key, index) => { return {}; }) }
}`
)
})
...
...
@@ -128,7 +128,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="value, , index in items" />`
,
`<view wx:for="{{a}}" wx:for-item="value"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (value, k0, index) => { return {}; }) }
return { a: _
f
(_ctx.items, (value, k0, index) => { return {}; }) }
}`
)
})
...
...
@@ -137,7 +137,7 @@ describe(`compiler: v-for`, () => {
`<view v-for=", , index in items" />`
,
`<view wx:for="{{a}}" wx:for-item="v0"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (v0, k0, index) => { return {}; }) }
return { a: _
f
(_ctx.items, (v0, k0, index) => { return {}; }) }
}`
)
})
...
...
@@ -146,7 +146,7 @@ describe(`compiler: v-for`, () => {
`<template v-for="item in items">hello<view/></template>`
,
`<block wx:for="{{a}}" wx:for-item="item">hello<view/></block>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -155,7 +155,7 @@ describe(`compiler: v-for`, () => {
`<template v-for="item in items"><slot/></template>`
,
`<block wx:for="{{a}}" wx:for-item="item"><slot/></block>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -165,7 +165,7 @@ describe(`compiler: v-for`, () => {
`<template v-for="item in items" :key="item.id"><view :id="item.id" /></template>`
,
`<block wx:for="{{a}}" wx:for-item="item" wx:key="b"><view id="{{item.a}}"/></block>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.id }; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.id }; }) }
}`
)
})
...
...
@@ -174,7 +174,7 @@ describe(`compiler: v-for`, () => {
`<slot v-for="item in items"></slot>`
,
`<slot wx:for="{{a}}" wx:for-item="item"></slot>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -183,7 +183,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="(item) in items" :key="item" />`
,
`<view wx:for="{{a}}" wx:for-item="item" wx:key="*this"/>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -192,7 +192,7 @@ describe(`compiler: v-for`, () => {
`<template v-for="item in items" :key="item">hello<view/></template>`
,
`<block wx:for="{{a}}" wx:for-item="item" wx:key="*this">hello<view/></block>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
@@ -201,7 +201,7 @@ describe(`compiler: v-for`, () => {
`<view v-if="ok" v-for="i in list"/>`
,
`<view wx:if="{{a}}" wx:for="{{b}}" wx:for-item="i"/>`
,
`(_ctx, _cache) => {
return _e
xtend({ a: _ctx.ok }, _ctx.ok ? { b: _vFor
(_ctx.list, (i, k0, i0) => { return {}; }) } : {})
return _e
({ a: _ctx.ok }, _ctx.ok ? { b: _f
(_ctx.list, (i, k0, i0) => { return {}; }) } : {})
}`
)
})
...
...
@@ -211,7 +211,7 @@ describe(`compiler: v-for`, () => {
`<template v-if="ok" v-for="i in list"/>`
,
`<block wx:if="{{a}}" wx:for="{{b}}" wx:for-item="i"/>`
,
`(_ctx, _cache) => {
return _e
xtend({ a: _ctx.ok }, _ctx.ok ? { b: _vFor
(_ctx.list, (i, k0, i0) => { return {}; }) } : {})
return _e
({ a: _ctx.ok }, _ctx.ok ? { b: _f
(_ctx.list, (i, k0, i0) => { return {}; }) } : {})
}`
)
})
...
...
@@ -615,7 +615,7 @@ describe(`compiler: v-for`, () => {
`<view v-for="item in items" :key="itemKey(item)">test</view>`
,
`<view wx:for="{{a}}" wx:for-item="item" wx:key="a">test</view>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return { a: _ctx.itemKey(item) }; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return { a: _ctx.itemKey(item) }; }) }
}`
)
})
...
...
@@ -626,7 +626,7 @@ describe(`compiler: v-for`, () => {
`<template v-for="item in items" :key="itemKey(item)">test</template>`
,
`<block wx:for="{{a}}" wx:for-item="item" wx:key="a">test</block>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return { a: _ctx.itemKey(item) }; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return { a: _ctx.itemKey(item) }; }) }
}`
)
})
...
...
@@ -636,7 +636,7 @@ describe(`compiler: v-for`, () => {
`<template v-for="item in items" key="key">test</template>`
,
`<block wx:for="{{a}}" wx:for-item="item" key="key">test</block>`
,
`(_ctx, _cache) => {
return { a: _
vFor
(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _
f
(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/vIf.spec.ts
浏览文件 @
f63216a6
...
...
@@ -29,7 +29,7 @@ describe(`compiler: v-if`, () => {
`<view v-if="ok"/>`
,
`<view wx:if="{{a}}"/>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : {})
return _e({ a: _ctx.ok }, _ctx.ok ? {} : {})
}`
)
})
...
...
@@ -38,7 +38,7 @@ describe(`compiler: v-if`, () => {
`<template v-if="ok"><view/>hello<view/></template>`
,
`<block wx:if="{{a}}"><view/>hello<view/></block>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : {})
return _e({ a: _ctx.ok }, _ctx.ok ? {} : {})
}`
)
})
...
...
@@ -47,7 +47,7 @@ describe(`compiler: v-if`, () => {
`<template v-if="ok"><slot/></template>`
,
`<block wx:if="{{a}}"><slot/></block>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : {})
return _e({ a: _ctx.ok }, _ctx.ok ? {} : {})
}`
)
})
...
...
@@ -56,7 +56,7 @@ describe(`compiler: v-if`, () => {
`<slot v-if="ok"/>`
,
`<slot wx:if="{{a}}"/>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : {})
return _e({ a: _ctx.ok }, _ctx.ok ? {} : {})
}`
)
})
...
...
@@ -65,7 +65,7 @@ describe(`compiler: v-if`, () => {
// `<Component v-if="ok"></Component>`,
// `<Component wx:if="{{a}}"></Component>`,
// `(_ctx, _cache) => {
// return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : {})
// return _e({ a: _ctx.ok }, _ctx.ok ? {} : {})
// }`
// )
})
...
...
@@ -74,7 +74,7 @@ describe(`compiler: v-if`, () => {
`<view v-if="ok"/><view v-else/>`
,
`<view wx:if="{{a}}"/><view wx:else/>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : {})
return _e({ a: _ctx.ok }, _ctx.ok ? {} : {})
}`
)
})
...
...
@@ -83,7 +83,7 @@ describe(`compiler: v-if`, () => {
`<view v-if="ok"/><view v-else-if="orNot"/>`
,
`<view wx:if="{{a}}"/><view wx:elif="{{b}}"/>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : {}, { b: _ctx.orNot })
return _e({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : {}, { b: _ctx.orNot })
}`
)
})
...
...
@@ -92,7 +92,7 @@ describe(`compiler: v-if`, () => {
`<view v-if="ok"/><view v-else-if="orNot"/><template v-else>fine</template>`
,
`<view wx:if="{{a}}"/><view wx:elif="{{b}}"/><block wx:else>fine</block>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : {}, { b: _ctx.orNot })
return _e({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : {}, { b: _ctx.orNot })
}`
)
})
...
...
@@ -119,7 +119,7 @@ describe(`compiler: v-if`, () => {
`<view v-if="ok"/><view v-else-if="orNot"/><view v-else-if="3"/><template v-else>fine</template>`
,
`<view wx:if="{{a}}"/><view wx:elif="{{b}}"/><view wx:elif="{{3}}"/><block wx:else>fine</block>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : 3 ? {} : {}, { b: _ctx.orNot })
return _e({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : 3 ? {} : {}, { b: _ctx.orNot })
}`
)
})
...
...
@@ -134,7 +134,7 @@ describe(`compiler: v-if`, () => {
`
,
`<view wx:if="{{a}}"/><view wx:elif="{{b}}"/><block wx:else>fine</block>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : {}, { b: _ctx.orNot })
return _e({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.orNot ? {} : {}, { b: _ctx.orNot })
}`
)
})
...
...
@@ -143,7 +143,7 @@ describe(`compiler: v-if`, () => {
`<view v-if="ok"/> <view v-else-if="no"/> <view v-else/>`
,
`<view wx:if="{{a}}"/><view wx:elif="{{b}}"/><view wx:else/>`
,
`(_ctx, _cache) => {
return _e
xtend
({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.no ? {} : {}, { b: _ctx.no })
return _e({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.no ? {} : {}, { b: _ctx.no })
}`
)
})
...
...
@@ -163,7 +163,7 @@ describe(`compiler: v-if`, () => {
`
,
`<block wx:if="{{a}}"><view wx:if="{{b}}"></view><view wx:else/><view/></block>`
,
`(_ctx, _cache) => {
return _e
xtend({ a: _ctx.ok }, _ctx.ok ? _extend
({ b: _ctx.ok2 }, _ctx.ok2 ? {} : {}) : {})
return _e
({ a: _ctx.ok }, _ctx.ok ? _e
({ b: _ctx.ok2 }, _ctx.ok2 ? {} : {}) : {})
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/vModel.spec.ts
浏览文件 @
f63216a6
...
...
@@ -6,7 +6,7 @@ describe('compiler: transform v-model', () => {
`<Comp v-model="model" />`
,
`<comp class="v-r" v-i="2a9ec0b0-0" modelValue="{{a}}" bindupdateModelValue="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.model, b: _
vOn
($event => _ctx.model = $event) }
return { a: _ctx.model, b: _
o
($event => _ctx.model = $event) }
}`
)
})
...
...
@@ -15,7 +15,7 @@ describe('compiler: transform v-model', () => {
`<Comp v-model="model" />`
,
`<comp class="v-r" v-i="2a9ec0b0-0" modelValue="{{a}}" bindupdateModelValue="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.model, b: _
vOn
($event => _ctx.model = $event) }
return { a: _ctx.model, b: _
o
($event => _ctx.model = $event) }
}`
,
{
cacheHandlers
:
true
,
...
...
@@ -27,14 +27,14 @@ describe('compiler: transform v-model', () => {
`<input v-model="model" />`
,
`<input value="{{a}}" bindinput="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.model, b: _
vOn
($event => _ctx.model = $event.detail.value) }
return { a: _ctx.model, b: _
o
($event => _ctx.model = $event.detail.value) }
}`
)
assert
(
`<textarea v-model="model" />`
,
`<textarea value="{{a}}" bindinput="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.model, b: _
vOn
($event => _ctx.model = $event.detail.value) }
return { a: _ctx.model, b: _
o
($event => _ctx.model = $event.detail.value) }
}`
)
})
...
...
@@ -43,7 +43,7 @@ describe('compiler: transform v-model', () => {
`<input @input="input" v-model="model" />`
,
`<input bindinput="{{a}}" value="{{b}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
([$event => _ctx.model = $event.detail.value, _ctx.input]), b: _ctx.model }
return { a: _
o
([$event => _ctx.model = $event.detail.value, _ctx.input]), b: _ctx.model }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/vOn.mp.spec.ts
浏览文件 @
f63216a6
...
...
@@ -25,7 +25,7 @@ describe('compiler(mp): transform v-on', () => {
`<editor @ready="ready"/>`
,
`<block wx:if="{{r0}}"><editor bindready="{{a}}"/></block>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(_ctx.ready) }
return { a: _
o
(_ctx.ready) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/vOn.spec.ts
浏览文件 @
f63216a6
...
...
@@ -17,7 +17,7 @@ describe('compiler: transform v-on', () => {
`<view v-on:click="onClick"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(_ctx.onClick) }
return { a: _
o
(_ctx.onClick) }
}`
)
})
...
...
@@ -35,7 +35,7 @@ describe('compiler: transform v-on', () => {
`<view @click="i++"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
($event => _ctx.i++) }
return { a: _
o
($event => _ctx.i++) }
}`
)
})
...
...
@@ -44,7 +44,7 @@ describe('compiler: transform v-on', () => {
`<view @click="foo();bar()"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
($event => { _ctx.foo(); _ctx.bar(); }) }
return { a: _
o
($event => { _ctx.foo(); _ctx.bar(); }) }
}`
)
})
...
...
@@ -54,9 +54,9 @@ describe('compiler: transform v-on', () => {
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
with (_ctx) {
const {
vOn: _vOn
} = _Vue
const {
o: _o
} = _Vue
return { a: _
vOn
($event => { foo(); bar(); }) }
return { a: _
o
($event => { foo(); bar(); }) }
}
}`
,
{
prefixIdentifiers
:
false
,
mode
:
'
function
'
}
...
...
@@ -67,7 +67,7 @@ describe('compiler: transform v-on', () => {
`<view @click="foo($event)"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
($event => _ctx.foo($event)) }
return { a: _
o
($event => _ctx.foo($event)) }
}`
)
})
...
...
@@ -76,7 +76,7 @@ describe('compiler: transform v-on', () => {
`<view @click="foo($event);bar()"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
($event => { _ctx.foo($event); _ctx.bar(); }) }
return { a: _
o
($event => { _ctx.foo($event); _ctx.bar(); }) }
}`
)
})
...
...
@@ -85,7 +85,7 @@ describe('compiler: transform v-on', () => {
`<view @click="$event => foo($event)"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
($event => _ctx.foo($event)) }
return { a: _
o
($event => _ctx.foo($event)) }
}`
)
})
...
...
@@ -98,7 +98,7 @@ describe('compiler: transform v-on', () => {
"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
($event => { _ctx.foo($event); }) }
return { a: _
o
($event => { _ctx.foo($event); }) }
}`
)
})
...
...
@@ -111,7 +111,7 @@ describe('compiler: transform v-on', () => {
"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(function ($event) { _ctx.foo($event); }) }
return { a: _
o
(function ($event) { _ctx.foo($event); }) }
}`
)
})
...
...
@@ -121,9 +121,9 @@ describe('compiler: transform v-on', () => {
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
with (_ctx) {
const {
vOn: _vOn
} = _Vue
const {
o: _o
} = _Vue
return { a: _
vOn
(a['b' + c]) }
return { a: _
o
(a['b' + c]) }
}
}`
,
{
...
...
@@ -137,7 +137,7 @@ describe('compiler: transform v-on', () => {
`<view @click="a['b' + c]"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(_ctx.a['b' + _ctx.c]) }
return { a: _
o
(_ctx.a['b' + _ctx.c]) }
}`
)
})
...
...
@@ -146,7 +146,7 @@ describe('compiler: transform v-on', () => {
`<view @click="e => foo(e)"/>`
,
`<view bindtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(e => _ctx.foo(e)) }
return { a: _
o
(e => _ctx.foo(e)) }
}`
)
})
...
...
@@ -178,7 +178,7 @@ describe('compiler: transform v-on', () => {
`<view v-on:foo-bar="onMount"/>`
,
`<view bind:foo-bar="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(_ctx.onMount) }
return { a: _
o
(_ctx.onMount) }
}`
)
})
...
...
@@ -188,7 +188,7 @@ describe('compiler: transform v-on', () => {
`<view v-on:vnode-mounted="onMount"/>`
,
`<view bind:vnode-mounted="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(_ctx.onMount) }
return { a: _
o
(_ctx.onMount) }
}`
)
})
...
...
@@ -199,7 +199,7 @@ describe('compiler: transform v-on', () => {
`<view v-on:click.prevent />`
,
`<view catchtap="{{a}}"/>`
,
`(_ctx, _cache) => {
return { a: _
vOn
(() => {}) }
return { a: _
o
(() => {}) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/vSlot.spec.ts
浏览文件 @
f63216a6
...
...
@@ -32,7 +32,7 @@ describe('compiler: transform v-slot', () => {
`<custom><template v-slot:default="slotProps"><view>{{ slotProps.item }}</view></template></custom>`
,
`<custom vue-slots="{{['default']}}" class="v-r" v-i="2a9ec0b0-0"><view slot="default"><view>{{a}}</view></view></custom>`
,
`(_ctx, _cache) => {
return { a: _t
oDisplayString
(_ctx.slotProps.item), b: slotProps }
return { a: _t(_ctx.slotProps.item), b: slotProps }
}`
)
})
...
...
packages/uni-mp-compiler/src/runtimeHelpers.ts
浏览文件 @
f63216a6
...
...
@@ -3,12 +3,18 @@ import { registerRuntimeHelpers } from '@vue/compiler-core'
export
const
V_ON
=
Symbol
(
`vOn`
)
export
const
V_FOR
=
Symbol
(
`vFor`
)
export
const
EXTEND
=
Symbol
(
`extend`
)
export
const
CAMELIZE
=
Symbol
(
`camelize`
)
export
const
HYPHENATE
=
Symbol
(
`hyphenate`
)
export
const
STRINGIFY_STYLE
=
Symbol
(
`stringifyStyle`
)
export
const
NORMALIZE_CLASS
=
Symbol
(
`normalizeClass`
)
export
const
TO_DISPLAY_STRING
=
Symbol
(
`toDisplayString`
)
registerRuntimeHelpers
({
[
V_ON
]:
'
vOn
'
,
[
V_FOR
]:
'
vFor
'
,
[
EXTEND
]:
'
extend
'
,
[
HYPHENATE
]:
'
hyphenate
'
,
[
STRINGIFY_STYLE
]:
'
stringifyStyle
'
,
[
V_ON
]:
'
o
'
,
[
V_FOR
]:
'
f
'
,
[
EXTEND
]:
'
e
'
,
[
CAMELIZE
]:
'
c
'
,
[
HYPHENATE
]:
'
h
'
,
[
STRINGIFY_STYLE
]:
'
s
'
,
[
NORMALIZE_CLASS
]:
'
n
'
,
[
TO_DISPLAY_STRING
]:
`t`
,
})
packages/uni-mp-compiler/src/transform.ts
浏览文件 @
f63216a6
...
...
@@ -528,9 +528,9 @@ function parseReturnObjExpr(prop: ObjectProperty) {
isObjectProperty
(
prop
)
&&
isCallExpression
(
prop
.
value
)
&&
isIdentifier
(
prop
.
value
.
callee
)
&&
prop
.
value
.
callee
.
name
===
'
_vFor
'
// 目前硬编码识别 _f,应该读取 context.helperString
prop
.
value
.
callee
.
name
===
'
_f
'
)
{
// 目前硬编码
return
(
(
(
prop
.
value
.
arguments
[
1
]
as
ArrowFunctionExpression
)
...
...
packages/uni-mp-compiler/src/transforms/transformClass.ts
浏览文件 @
f63216a6
...
...
@@ -27,11 +27,11 @@ import {
createSimpleExpression
,
ExpressionNode
,
createCompoundExpression
,
NORMALIZE_CLASS
,
SourceLocation
,
}
from
'
@vue/compiler-core
'
import
{
parseExpr
,
isTrueExpr
,
isUndefined
,
parseStringLiteral
}
from
'
../ast
'
import
{
genBabelExpr
}
from
'
../codegen
'
import
{
NORMALIZE_CLASS
}
from
'
../runtimeHelpers
'
import
{
TransformContext
}
from
'
../transform
'
import
{
parseExprWithRewrite
,
...
...
packages/uni-mp-compiler/src/transforms/transformIdentifier.ts
浏览文件 @
f63216a6
...
...
@@ -2,7 +2,6 @@ import {
createCompoundExpression
,
DirectiveNode
,
NodeTypes
,
TO_DISPLAY_STRING
,
}
from
'
@vue/compiler-core
'
import
{
NodeTransform
}
from
'
../transform
'
...
...
@@ -19,6 +18,7 @@ import {
isStyleBinding
,
rewriteStyle
,
}
from
'
./transformStyle
'
import
{
TO_DISPLAY_STRING
}
from
'
../runtimeHelpers
'
export
const
transformIdentifier
:
NodeTransform
=
(
node
,
context
)
=>
{
return
()
=>
{
...
...
packages/uni-mp-compiler/src/transforms/vBind.ts
浏览文件 @
f63216a6
import
{
camelize
}
from
'
@vue/shared
'
import
{
NodeTypes
,
CAMELIZE
,
createCompilerError
,
ErrorCodes
,
createObjectProperty
,
...
...
@@ -27,7 +26,7 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => {
if
(
arg
.
isStatic
)
{
arg
.
content
=
camelize
(
arg
.
content
)
}
else
{
arg
.
content
=
`
${
context
.
helperString
(
CAMELIZE
)}
(
${
arg
.
content
}
)`
//
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`
}
}
else
{
// arg.children.unshift(`${context.helperString(CAMELIZE)}(`)
...
...
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
f63216a6
import
{
extend
,
isSymbol
,
isObject
,
toRawType
,
def
,
hasChanged
,
isArray
,
isFunction
,
NOOP
,
remove
,
toHandlerKey
,
camelize
,
capitalize
,
isString
,
normalizeClass
,
normalizeStyle
,
isOn
,
isPromise
,
EMPTY_OBJ
,
isSet
,
isMap
,
isPlainObject
,
invokeArrayFns
,
hasOwn
,
NO
,
isIntegerKey
,
toNumber
,
hyphenate
,
isReservedProp
,
EMPTY_ARR
,
makeMap
,
toTypeString
,
stringifyStyle
as
stringifyStyle$1
}
from
'
@vue/shared
'
;
export
{
camelize
,
extend
,
hyphenate
,
normalizeClass
,
normalizeProps
,
normalizeStyle
,
toDisplayString
,
toHandlerKey
}
from
'
@vue/shared
'
;
export
{
camelize
as
c
,
camelize
,
extend
as
e
,
hyphenate
as
h
,
normalizeClass
as
n
,
normalizeClass
,
normalizeProps
,
normalizeStyle
,
toDisplayString
as
t
,
toDisplayString
,
toHandlerKey
}
from
'
@vue/shared
'
;
// lifecycle
// App and Page
...
...
@@ -5068,4 +5068,4 @@ function createApp(rootComponent, rootProps = null) {
}
const
createSSRApp
=
createApp
;
export
{
EffectScope
,
ReactiveEffect
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed
,
createApp
,
createSSRApp
,
createVNode$1
as
createVNode
,
createVueApp
,
customRef
,
defineComponent
,
defineEmits
,
defineExpose
,
defineProps
,
effect
,
effectScope
,
getCurrentInstance
,
getCurrentScope
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
mergeDefaults
,
mergeProps
,
nextTick
,
onActivated
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onScopeDispose
,
onUnmounted
,
onUpdated
,
provide
,
proxyRefs
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
resolveComponent
,
resolveDirective
,
resolveFilter
,
setupDevtoolsPlugin
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
stop
,
stringifyStyle
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
useAttrs
,
useSSRContext
,
useSlots
,
vFor
,
vOn
,
version
,
warn$1
as
warn
,
watch
,
watchEffect
,
watchPostEffect
,
watchSyncEffect
,
withAsyncContext
,
withCtx
,
withDefaults
,
withDirectives
,
withModifiers
,
withScopeId
};
export
{
EffectScope
,
ReactiveEffect
,
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed
,
createApp
,
createSSRApp
,
createVNode$1
as
createVNode
,
createVueApp
,
customRef
,
defineComponent
,
defineEmits
,
defineExpose
,
defineProps
,
effect
,
effectScope
,
vFor
as
f
,
getCurrentInstance
,
getCurrentScope
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
mergeDefaults
,
mergeProps
,
nextTick
,
vOn
as
o
,
onActivated
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onScopeDispose
,
onUnmounted
,
onUpdated
,
provide
,
proxyRefs
,
queuePostFlushCb
,
reactive
,
readonly
,
ref
,
resolveComponent
,
resolveDirective
,
resolveFilter
,
stringifyStyle
as
s
,
setupDevtoolsPlugin
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
stop
,
toHandlers
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
useAttrs
,
useSSRContext
,
useSlots
,
version
,
warn$1
as
warn
,
watch
,
watchEffect
,
watchPostEffect
,
watchSyncEffect
,
withAsyncContext
,
withCtx
,
withDefaults
,
withDirectives
,
withModifiers
,
withScopeId
};
packages/uni-mp-vue/src/index.ts
浏览文件 @
f63216a6
...
...
@@ -6,7 +6,18 @@ export function createApp(rootComponent: unknown, rootProps = null) {
return
createVueApp
(
rootComponent
,
rootProps
).
use
(
plugin
)
}
export
const
createSSRApp
=
createApp
export
*
from
'
./helpers
'
export
{
extend
,
hyphenate
}
from
'
@vue/shared
'
export
{
vOn
as
o
,
vFor
as
f
,
stringifyStyle
as
s
,
setupDevtoolsPlugin
,
}
from
'
./helpers
'
export
{
camelize
as
c
,
extend
as
e
,
hyphenate
as
h
,
normalizeClass
as
n
,
toDisplayString
as
t
,
}
from
'
@vue/shared
'
// @ts-ignore
export
*
from
'
../lib/vue.runtime.esm.js
'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录