Ver Fonte

record original tag name on vnode for components using is attribute

Evan You há 10 anos atrás
pai
commit
4bcdce895c
3 ficheiros alterados com 8 adições e 2 exclusões
  1. 2 0
      flow/vnode.js
  2. 4 0
      src/compiler/codegen.js
  3. 2 2
      test/unit/modules/compiler/codegen.spec.js

+ 2 - 0
flow/vnode.js

@@ -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;

+ 4 - 0
src/compiler/codegen.js

@@ -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},`

+ 2 - 2
test/unit/modules/compiler/codegen.spec.js

@@ -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"}))}`
     )
   })