Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
feb6cc74
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
feb6cc74
编写于
12月 08, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp): transform props without special attributes (#3055)
上级
7bb7a767
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
9 addition
and
13 deletion
+9
-13
packages/uni-mp-compiler/__tests__/component.spec.ts
packages/uni-mp-compiler/__tests__/component.spec.ts
+3
-3
packages/uni-mp-compiler/__tests__/vFor.spec.ts
packages/uni-mp-compiler/__tests__/vFor.spec.ts
+4
-4
packages/uni-mp-compiler/src/transforms/transformComponent.ts
...ages/uni-mp-compiler/src/transforms/transformComponent.ts
+2
-0
packages/uni-mp-compiler/src/transforms/transformIdentifier.ts
...ges/uni-mp-compiler/src/transforms/transformIdentifier.ts
+0
-6
未找到文件。
packages/uni-mp-compiler/__tests__/component.spec.ts
浏览文件 @
feb6cc74
...
...
@@ -99,10 +99,10 @@ describe('compiler: transform component', () => {
})
test
(
`component with props`
,
()
=>
{
assert
(
`<uni-collapse ref="a" :ref="b" slot="c" :slot="d" class="e" :class="f" style="g" :style="h" @click="i" v-model:first="j" v-model:last="k" prop-a="l" :prop-b="m" data-a="n" :data-b="o" />`
,
`<uni-collapse ref="a" ref="{{a}}" slot="c" slot="{{b}}" class="{{['e', c]}}" style="{{'g' + ';' + d}}" bindclick="{{e}}" data-a="n" data-b="{{f}}"
u-i="2a9ec0b0-0" bindupdateFirst="{{g}}" bindupdateLast="{{h}}" u-p="{{i
}}"/>`
,
`<uni-collapse ref="a" :ref="b" slot="c" :slot="d" class="e" :class="f" style="g" :style="h" @click="i" v-model:first="j" v-model:last="k" prop-a="l" :prop-b="m" data-a="n" :data-b="o"
key="p" :key="r" is="s" :is="t"
/>`
,
`<uni-collapse ref="a" ref="{{a}}" slot="c" slot="{{b}}" class="{{['e', c]}}" style="{{'g' + ';' + d}}" bindclick="{{e}}" data-a="n" data-b="{{f}}"
key="p" key="{{g}}" is="s" is="{{h}}" u-i="2a9ec0b0-0" bindupdateFirst="{{i}}" bindupdateLast="{{j}}" u-p="{{k
}}"/>`
,
`(_ctx, _cache) => {
return { a: _ctx.b, b: _ctx.d, c: _n(_ctx.f), d: _s(_ctx.h), e: _o(_ctx.i), f: _ctx.o, g: _
o($event => _ctx.j = $event), h: _o($event => _ctx.k = $event), i
: _p({ ['prop-a']: 'l', ['prop-b']: _ctx.m, first: _ctx.j, last: _ctx.k }) }
return { a: _ctx.b, b: _ctx.d, c: _n(_ctx.f), d: _s(_ctx.h), e: _o(_ctx.i), f: _ctx.o, g: _
ctx.r, h: _ctx.t, i: _o($event => _ctx.j = $event), j: _o($event => _ctx.k = $event), k
: _p({ ['prop-a']: 'l', ['prop-b']: _ctx.m, first: _ctx.j, last: _ctx.k }) }
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/vFor.spec.ts
浏览文件 @
feb6cc74
...
...
@@ -186,18 +186,18 @@ describe(`compiler: v-for`, () => {
test
(
`keyed v-for`
,
()
=>
{
assert
(
`<view v-for="(item) in items" :key="item" />`
,
`<view wx:for="{{a}}" wx:for-item="item" wx:key="
*this
"/>`
,
`<view wx:for="{{a}}" wx:for-item="item" wx:key="
a
"/>`
,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _f(_ctx.items, (item, k0, i0) => { return {
a: item
}; }) }
}`
)
})
test
(
`keyed template v-for`
,
()
=>
{
assert
(
`<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>`
,
`<block wx:for="{{a}}" wx:for-item="item" wx:key="
a
">hello<view/></block>`
,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return {}; }) }
return { a: _f(_ctx.items, (item, k0, i0) => { return {
a: item
}; }) }
}`
)
})
...
...
packages/uni-mp-compiler/src/transforms/transformComponent.ts
浏览文件 @
feb6cc74
...
...
@@ -103,6 +103,8 @@ function isComponentProp(name: string) {
'
onVI
'
,
'
ref
'
,
'
slot
'
,
'
key
'
,
'
is
'
,
].
includes
(
name
)
)
{
return
false
...
...
packages/uni-mp-compiler/src/transforms/transformIdentifier.ts
浏览文件 @
feb6cc74
...
...
@@ -6,9 +6,7 @@ import {
}
from
'
@vue/compiler-core
'
import
{
NodeTransform
}
from
'
../transform
'
import
{
isForElementNode
}
from
'
./vFor
'
import
{
ATTR_VUE_SLOTS
,
rewriteExpression
}
from
'
./utils
'
import
{
isSelfKey
,
rewriteSelfKey
}
from
'
./transformKey
'
import
{
findStaticClassIndex
,
isClassBinding
,
...
...
@@ -44,8 +42,6 @@ export const transformIdentifier: NodeTransform = (node, context) => {
}
else
if
(
isSlotOutlet
(
node
))
{
rewriteSlot
(
node
,
context
)
}
else
if
(
node
.
type
===
NodeTypes
.
ELEMENT
)
{
const
vFor
=
isForElementNode
(
node
)
&&
node
.
vFor
let
hasClassBinding
=
false
let
hasStyleBinding
=
false
...
...
@@ -78,8 +74,6 @@ export const transformIdentifier: NodeTransform = (node, context) => {
if
(
exp
)
{
if
(
isBuiltIn
(
dir
))
{
// noop
}
else
if
(
isSelfKey
(
dir
,
vFor
))
{
rewriteSelfKey
(
dir
)
}
else
if
(
isClassBinding
(
dir
))
{
hasClassBinding
=
true
rewriteClass
(
i
,
dir
,
props
,
context
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录