提交 9f22b637 编写于 作者: Q qiang

fix(App): slot name dynamic data (question/95109)

上级 dd5a4988
......@@ -178,6 +178,10 @@ describe('codegen', () => {
'<div><slot name="one"></slot></div>',
`with(this){return _c('div',[_t("one",null,{"_i":1})],2)}`
)
assertCodegen(
'<div><slot :name="one"></slot></div>',
`with(this){return _c('div',[_t(_$s(1,'name',one),null,{"_i":1})],2)}`
)
})
it('generate slot fallback content', () => {
......
......@@ -178,6 +178,10 @@ describe('codegen', () => {
'<div><slot name="one"></slot></div>',
`with(this){return _c('div',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}`
)
assertCodegen(
'<div><slot :name="one"></slot></div>',
`with(this){return _c('div',{attrs:{"_i":0}},[_t(_$g(1,'name'),null,{"_i":1})],2)}`
)
})
it('generate slot fallback content', () => {
......
......@@ -2,6 +2,7 @@ const {
ID,
C_IS,
C_REF,
C_NAME,
V_IF,
V_FOR,
V_ELSE_IF,
......@@ -16,6 +17,12 @@ function parseRef (el, genVar) {
}
}
function parseSlotName (el, genVar) {
if (el.slotName && isVar(el.slotName)) {
el.slotName = genVar(C_NAME, el.slotName)
}
}
function parseIs (el, genVar) {
if (!el.component) {
return
......@@ -106,6 +113,7 @@ function parseText (el, parent, state) {
module.exports = {
parseIs,
parseRef,
parseSlotName,
parseIf,
parseFor,
parseText,
......
......@@ -18,6 +18,7 @@ const {
const {
parseIs,
parseRef,
parseSlotName,
parseIf,
parseFor,
parseText,
......@@ -137,6 +138,7 @@ function transformNode (el, parent, state, isScopedSlot) {
parseIs(el, genVar)
parseRef(el, genVar)
parseSlotName(el, genVar)
parseFor(el, createGenVar, isScopedSlot, checkAutoFill(el))
parseKey(el, isScopedSlot)
......
......@@ -15,6 +15,7 @@ const GET_CHANGE_DATA = '_$gc' // wxs
const C_IS = 'is'
const C_SLOT_TARGET = 'st'
const C_REF = 'ref'
const C_NAME = 'name'
const V_FOR = 'f'
const V_IF = 'i'
......@@ -268,6 +269,7 @@ function addHandler (el, name, value, important) {
module.exports = {
C_IS,
C_REF,
C_NAME,
V_FOR,
V_IF,
V_ELSE_IF,
......
......@@ -13,6 +13,7 @@ const {
const {
parseIs,
parseRef,
parseSlotName,
parseIf,
parseFor,
parseText,
......@@ -130,6 +131,7 @@ function transformNode (el, parent, state, isScopedSlot) {
parseIs(el, genVar)
parseRef(el, genVar)
parseSlotName(el, genVar)
if (parseFor(el, createGenVar, isScopedSlot)) {
if (el.alias[0] === '{') { // <div><li v-for=" { a, b } in items"></li></div>
el.alias = '$item'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册