]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(v-model): enable v-model type detection on custom elements
authorEvan You <yyx990803@gmail.com>
Tue, 28 Jul 2020 15:44:27 +0000 (11:44 -0400)
committerEvan You <yyx990803@gmail.com>
Tue, 28 Jul 2020 15:44:39 +0000 (11:44 -0400)
packages/compiler-dom/src/transforms/vModel.ts

index 83984d23e73d2202e86c6f4ae88494c78fea7823..0aa9dca1eb8750bb94cdbf648bd18fac21ae0d9c 100644 (file)
@@ -44,15 +44,16 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
   }
 
   const { tag } = node
+  const isCustomElement = context.isCustomElement(tag)
   if (
     tag === 'input' ||
     tag === 'textarea' ||
     tag === 'select' ||
-    context.isCustomElement(tag)
+    isCustomElement
   ) {
     let directiveToUse = V_MODEL_TEXT
     let isInvalidType = false
-    if (tag === 'input') {
+    if (tag === 'input' || isCustomElement) {
       const type = findProp(node, `type`)
       if (type) {
         if (type.type === NodeTypes.DIRECTIVE) {
@@ -91,9 +92,8 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
       }
     } else if (tag === 'select') {
       directiveToUse = V_MODEL_SELECT
-    }
-    {
-      // textarea or custom elements
+    } else {
+      // textarea
       __DEV__ && checkDuplicatedValue()
     }
     // inject runtime directive