Procházet zdrojové kódy

props: only warn twoWay when prop is present (fix #1400)

Evan You před 10 roky
rodič
revize
d8862a1774
1 změnil soubory, kde provedl 12 přidání a 11 odebrání
  1. 12 11
      src/compiler/compile-props.js

+ 12 - 11
src/compiler/compile-props.js

@@ -85,6 +85,18 @@ module.exports = function compileProps (el, propOptions) {
           }
         }
         prop.parentPath = value
+
+        // warn required two-way
+        if (
+          process.env.NODE_ENV !== 'production' &&
+          options.twoWay &&
+          prop.mode !== propBindingModes.TWO_WAY
+        ) {
+          _.warn(
+            'Prop "' + name + '" expects a two-way binding type.'
+          )
+        }
+
       } else if (options.required) {
         // warn missing required
         process.env.NODE_ENV !== 'production' && _.warn(
@@ -93,17 +105,6 @@ module.exports = function compileProps (el, propOptions) {
       }
     }
 
-    // warn required two-way
-    if (
-      process.env.NODE_ENV !== 'production' &&
-      options.twoWay &&
-      prop.mode !== propBindingModes.TWO_WAY
-    ) {
-      _.warn(
-        'Prop "' + name + '" expects a two-way binding type.'
-      )
-    }
-
     // push prop
     props.push(prop)
   }