Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
9670649b
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
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,发现更多精彩内容 >>
提交
9670649b
编写于
10月 29, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
wip(mp): mp-alipay
上级
275b578e
2a7c2df4
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
42 addition
and
19 deletion
+42
-19
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+1
-1
packages/uni-cloud/dist/uni-cloud.cjs.js
packages/uni-cloud/dist/uni-cloud.cjs.js
+1
-1
packages/uni-cloud/dist/uni-cloud.es.js
packages/uni-cloud/dist/uni-cloud.es.js
+1
-1
packages/uni-components/src/components/picker-view-column/index.tsx
...ni-components/src/components/picker-view-column/index.tsx
+1
-0
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+1
-0
packages/uni-mp-compiler/__tests__/test.spec.ts
packages/uni-mp-compiler/__tests__/test.spec.ts
+3
-3
packages/uni-mp-compiler/__tests__/vBind.spec.ts
packages/uni-mp-compiler/__tests__/vBind.spec.ts
+9
-0
packages/uni-mp-compiler/src/transforms/transformClass.ts
packages/uni-mp-compiler/src/transforms/transformClass.ts
+2
-2
packages/uni-mp-compiler/src/transforms/transformStyle.ts
packages/uni-mp-compiler/src/transforms/transformStyle.ts
+2
-3
packages/uni-mp-compiler/src/transforms/utils.ts
packages/uni-mp-compiler/src/transforms/utils.ts
+15
-2
packages/uni-mp-compiler/src/transforms/vFor.ts
packages/uni-mp-compiler/src/transforms/vFor.ts
+4
-2
packages/uni-mp-compiler/src/transforms/vIf.ts
packages/uni-mp-compiler/src/transforms/vIf.ts
+2
-4
未找到文件。
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
9670649b
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
packages/uni-cloud/dist/uni-cloud.cjs.js
浏览文件 @
9670649b
此差异已折叠。
点击以展开。
packages/uni-cloud/dist/uni-cloud.es.js
浏览文件 @
9670649b
此差异已折叠。
点击以展开。
packages/uni-components/src/components/picker-view-column/index.tsx
浏览文件 @
9670649b
...
...
@@ -230,6 +230,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
break
case
'
move
'
:
handleTouchMove
(
e
)
e
.
stopPropagation
()
break
case
'
end
'
:
case
'
cancel
'
:
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
9670649b
...
...
@@ -10937,6 +10937,7 @@ var PickerViewColumn = /* @__PURE__ */ defineBuiltInComponent({
break;
case "move":
handleTouchMove(e2);
e2.stopPropagation();
break;
case "end":
case "cancel":
...
...
packages/uni-mp-compiler/__tests__/test.spec.ts
浏览文件 @
9670649b
...
...
@@ -38,10 +38,10 @@ function assert(
describe
(
'
compiler
'
,
()
=>
{
test
(
'
scope
'
,
()
=>
{
assert
(
`<
custom :ref="custom
"/>`
,
`<
custom class="v-r" data-ref="{{a}}" v-i="2a9ec0b0-0
"/>`
,
`<
view :number="20" :str="'str'" :boolean="true" :null="null" :undefined="undefined
"/>`
,
`<
view number="{{20}}" str="{{'str'}}" boolean="{{true}}" null="{{null}}" undefined="{{undefined}}
"/>`
,
`(_ctx, _cache) => {
return {
a: _ctx.custom
}
return {}
}`
)
})
...
...
packages/uni-mp-compiler/__tests__/vBind.spec.ts
浏览文件 @
9670649b
...
...
@@ -29,6 +29,15 @@ describe('compiler: transform v-bind', () => {
)
})
test
(
'
literal
'
,
()
=>
{
assert
(
`<view :number="20" :str="'str'" :boolean="true" :null="null" :undefined="undefined"/>`
,
`<view number="{{20}}" str="{{'str'}}" boolean="{{true}}" null="{{null}}" undefined="{{undefined}}"/>`
,
`(_ctx, _cache) => {
return {}
}`
)
})
test
(
'
dynamic arg
'
,
()
=>
{
const
onError
=
jest
.
fn
()
parseWithVBind
(
`<view v-bind:[id]="id" />`
,
{
...
...
packages/uni-mp-compiler/src/transforms/transformClass.ts
浏览文件 @
9670649b
...
...
@@ -18,7 +18,6 @@ import {
LogicalExpression
,
logicalExpression
,
StringLiteral
,
isTemplateLiteral
,
parenthesizedExpression
,
binaryExpression
,
}
from
'
@babel/types
'
...
...
@@ -36,6 +35,7 @@ import { genBabelExpr } from '../codegen'
import
{
NORMALIZE_CLASS
}
from
'
../runtimeHelpers
'
import
{
TransformContext
}
from
'
../transform
'
import
{
isStaticLiteral
,
parseExprWithRewrite
,
parseExprWithRewriteClass
,
rewriteExpression
,
...
...
@@ -197,7 +197,7 @@ function rewriteClassObjectExpression(
key
as
Expression
)
as
Identifier
}
if
(
is
Literal
(
value
)
&&
!
isTemplate
Literal
(
value
))
{
if
(
is
Static
Literal
(
value
))
{
return
}
else
{
const
newExpr
=
parseExprWithRewriteClass
(
...
...
packages/uni-mp-compiler/src/transforms/transformStyle.ts
浏览文件 @
9670649b
...
...
@@ -9,11 +9,9 @@ import {
isSpreadElement
,
identifier
,
ObjectExpression
,
isLiteral
,
isObjectProperty
,
binaryExpression
,
isIdentifier
,
isTemplateLiteral
,
}
from
'
@babel/types
'
import
{
DirectiveNode
,
...
...
@@ -30,6 +28,7 @@ import { parseExpr, parseStringLiteral } from '../ast'
import
{
genBabelExpr
}
from
'
../codegen
'
import
{
TransformContext
}
from
'
../transform
'
import
{
isStaticLiteral
,
parseExprWithRewrite
,
rewirteWithHelper
,
rewriteExpression
,
...
...
@@ -160,7 +159,7 @@ function rewriteStyleObjectExpression(
prop
.
key
.
value
=
hyphenate
(
prop
.
key
.
value
)
+
'
:
'
}
// {fontSize:`${fontSize}px`} => {'font-size':a}
if
(
is
Literal
(
value
)
&&
!
isTemplate
Literal
(
value
))
{
if
(
is
Static
Literal
(
value
))
{
return
}
else
{
const
newExpr
=
parseExprWithRewrite
(
...
...
packages/uni-mp-compiler/src/transforms/utils.ts
浏览文件 @
9670649b
...
...
@@ -4,7 +4,9 @@ import {
Identifier
,
identifier
,
isIdentifier
,
isLiteral
,
isReferenced
,
isTemplateLiteral
,
MemberExpression
,
numericLiteral
,
objectProperty
,
...
...
@@ -15,6 +17,7 @@ import {
createSimpleExpression
,
ExpressionNode
,
NodeTypes
,
SimpleExpressionNode
,
SourceLocation
,
}
from
'
@vue/compiler-core
'
import
{
walk
,
BaseNode
}
from
'
estree-walker
'
...
...
@@ -86,14 +89,17 @@ export function rewriteExpressionWithoutProperty(
babelNode
?:
Expression
,
scope
:
CodegenScope
=
context
.
currentScope
)
{
return
rewriteExpression
(
node
,
context
,
babelNode
,
scope
,
false
)
return
rewriteExpression
(
node
,
context
,
babelNode
,
scope
,
{
property
:
false
,
ignoreLiteral
:
false
,
})
}
export
function
rewriteExpression
(
node
:
ExpressionNode
,
context
:
TransformContext
,
babelNode
?:
Expression
,
scope
:
CodegenScope
=
context
.
currentScope
,
property
:
boolean
=
true
{
property
,
ignoreLiteral
}
=
{
property
:
true
,
ignoreLiteral
:
false
}
)
{
if
(
node
.
type
===
NodeTypes
.
SIMPLE_EXPRESSION
&&
node
.
isStatic
)
{
return
node
...
...
@@ -105,6 +111,9 @@ export function rewriteExpression(
return
createSimpleExpression
(
code
)
}
}
if
(
!
ignoreLiteral
&&
isStaticLiteral
(
babelNode
))
{
return
node
as
SimpleExpressionNode
}
if
(
isUndefined
(
babelNode
))
{
return
createSimpleExpression
(
'
undefined
'
,
false
,
node
.
loc
)
}
...
...
@@ -169,3 +178,7 @@ function isReferencedByIds(node: Expression, knownIds: string[]) {
})
return
referenced
}
export
function
isStaticLiteral
(
value
:
object
|
null
|
undefined
)
{
return
isLiteral
(
value
)
&&
!
isTemplateLiteral
(
value
)
}
packages/uni-mp-compiler/src/transforms/vFor.ts
浏览文件 @
9670649b
...
...
@@ -104,13 +104,15 @@ export const transformFor = createStructuralDirectiveTransform(
const
indexCode
=
genExpr
(
index
)
const
indexExpr
=
parseParam
(
indexCode
,
context
,
index
)
const
indexAlias
=
parseAlias
(
indexExpr
,
indexCode
,
'
i
'
+
scopes
.
vFor
)
// 先占位vFor,后续更新 cloneSourceExpr 为 CallExpression
// 先占位
vFor,后续更新 cloneSourceExpr 为 CallExpression
const
cloneSourceExpr
=
cloneNode
(
sourceExpr
!
,
false
)
const
sourceAlias
=
rewriteExpression
(
source
,
context
,
cloneSourceExpr
,
parentScope
parentScope
,
// 强制 rewrite,因为即使是字符串,数字,也要走 vFor 函数
{
property
:
true
,
ignoreLiteral
:
true
}
).
content
const
sourceCode
=
`{{
${
sourceAlias
}
}}`
const
vForData
:
VForOptions
=
{
...
...
packages/uni-mp-compiler/src/transforms/vIf.ts
浏览文件 @
9670649b
import
{
ConditionalExpression
,
isConditionalExpression
,
isLiteral
,
isTemplateLiteral
,
isSpreadElement
,
ObjectExpression
,
}
from
'
@babel/types
'
...
...
@@ -31,7 +29,7 @@ import {
traverseNode
,
}
from
'
../transform
'
import
{
processExpression
}
from
'
./transformExpression
'
import
{
rewriteExpression
}
from
'
./utils
'
import
{
isStaticLiteral
,
rewriteExpression
}
from
'
./utils
'
interface
IfOptions
{
name
:
string
condition
?:
string
...
...
@@ -59,7 +57,7 @@ export const transformIf = createStructuralDirectiveTransform(
condition
,
})
if
(
condition
)
{
if
(
!
is
Literal
(
condition
)
||
isTemplate
Literal
(
condition
))
{
if
(
!
is
Static
Literal
(
condition
))
{
ifOptions
.
condition
=
rewriteExpression
(
dir
.
exp
!
,
context
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录