record original tag name on vnode for components using is attribute

This commit is contained in:
Evan You 2016-06-02 18:18:32 -04:00
parent 113232f960
commit 4bcdce895c
3 changed files with 8 additions and 2 deletions

View File

@ -32,6 +32,8 @@ declare interface VNodeWithData {
declare interface VNodeData {
key?: string | number;
slot?: string;
ref?: string;
tag?: string;
staticClass?: string;
class?: any;
style?: Array<Object> | Object;

View File

@ -119,6 +119,10 @@ function genData (el: ASTElement): string | void {
if (el.refInFor) {
data += `refInFor:true,`
}
// record original tag name for components using "is" attribute
if (el.component) {
data += `tag:"${el.tag}",`
}
// slot target
if (el.slotTarget) {
data += `slot:${el.slotTarget},`

View File

@ -302,11 +302,11 @@ describe('codegen', () => {
it('generate is attribute', () => {
assertCodegen(
'<div is="component1"></div>',
`with(this){return _h(_e("component1",{}))}`
`with(this){return _h(_e("component1",{tag:"div"}))}`
)
assertCodegen(
'<div :is="component1"></div>',
`with(this){return _h(_e(component1,{}))}`
`with(this){return _h(_e(component1,{tag:"div"}))}`
)
})