ソースを参照

fix(compiler): maybeComponent should return true when "is" attribute exists (#8114)

close #8101
Jovino Xu 7 年 前
コミット
aef2a5f3db

+ 1 - 1
src/compiler/codegen/index.js

@@ -26,7 +26,7 @@ export class CodegenState {
     this.dataGenFns = pluckModuleFunction(options.modules, 'genData')
     this.directives = extend(extend({}, baseDirectives), options.directives)
     const isReservedTag = options.isReservedTag || no
-    this.maybeComponent = (el: ASTElement) => !isReservedTag(el.tag)
+    this.maybeComponent = (el: ASTElement) => !(isReservedTag(el.tag) && !el.component)
     this.onceId = 0
     this.staticRenderFns = []
   }

+ 5 - 0
test/unit/modules/compiler/codegen.spec.js

@@ -524,6 +524,11 @@ describe('codegen', () => {
       '<div :is="component1"></div>',
       `with(this){return _c(component1,{tag:"div"})}`
     )
+    // maybe a component and normalize type should be 1
+    assertCodegen(
+      '<div><div is="component1"></div></div>',
+      `with(this){return _c('div',[_c("component1",{tag:"div"})],1)}`
+    )
   })
 
   it('generate component with inline-template', () => {