]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): only check is prop on `<component>`
authorEvan You <yyx990803@gmail.com>
Fri, 31 Jan 2020 21:15:05 +0000 (16:15 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 31 Jan 2020 21:15:05 +0000 (16:15 -0500)
packages/compiler-core/src/transforms/transformElement.ts

index 0d907498b67ca7f1beb467bc3129e07502db1104..65963da280eebc9a3f6c464d77af1c14dda57368 100644 (file)
@@ -73,27 +73,25 @@ export const transformElement: NodeTransform = (node, context) => {
     let shouldUseBlock = false
 
     // handle dynamic component
-    const isProp = findProp(node, 'is')
-    if (tag === 'component') {
-      if (isProp) {
-        // static <component is="foo" />
-        if (isProp.type === NodeTypes.ATTRIBUTE) {
-          const tag = isProp.value && isProp.value.content
-          if (tag) {
-            context.helper(RESOLVE_COMPONENT)
-            context.components.add(tag)
-            dynamicComponent = toValidAssetId(tag, `component`)
-          }
-        }
-        // dynamic <component :is="asdf" />
-        else if (isProp.exp) {
-          dynamicComponent = createCallExpression(
-            context.helper(RESOLVE_DYNAMIC_COMPONENT),
-            // _ctx.$ exposes the owner instance of current render function
-            [isProp.exp, context.prefixIdentifiers ? `_ctx.$` : `$`]
-          )
+    const isProp = tag === 'component' && findProp(node, 'is')
+    if (isProp) {
+      // static <component is="foo" />
+      if (isProp.type === NodeTypes.ATTRIBUTE) {
+        const tag = isProp.value && isProp.value.content
+        if (tag) {
+          context.helper(RESOLVE_COMPONENT)
+          context.components.add(tag)
+          dynamicComponent = toValidAssetId(tag, `component`)
         }
       }
+      // dynamic <component :is="asdf" />
+      else if (isProp.exp) {
+        dynamicComponent = createCallExpression(
+          context.helper(RESOLVE_DYNAMIC_COMPONENT),
+          // _ctx.$ exposes the owner instance of current render function
+          [isProp.exp, context.prefixIdentifiers ? `_ctx.$` : `$`]
+        )
+      }
     }
 
     let nodeType