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

fix(mp): transform props without special attributes (#3055)

上级 7bb7a767
......@@ -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 }) }
}`
)
})
......
......@@ -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 }; }) }
}`
)
})
......
......@@ -103,6 +103,8 @@ function isComponentProp(name: string) {
'onVI',
'ref',
'slot',
'key',
'is',
].includes(name)
) {
return false
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册