Explorar el Código

warn improper props

Evan You hace 10 años
padre
commit
f63618eeb2
Se han modificado 1 ficheros con 9 adiciones y 0 borrados
  1. 9 0
      src/compiler/compile.js

+ 9 - 0
src/compiler/compile.js

@@ -9,6 +9,7 @@ var resolveAsset = _.resolveAsset
 var componentDef = require('../directives/component')
 
 // special binding prefixes
+var propRE = /^prop-/
 var bindRE = /^bind-/
 var onRE = /^on-/
 
@@ -584,6 +585,14 @@ function compileDirectives (attrs, options) {
       })
     } else
 
+    // should not see props here
+    if (process.env.NODE_ENV !== 'production' && propRE.test(name)) {
+      _.warn(
+        name + '="' + value + '" is not compiled. It\'s either not declared ' +
+        'on the child component, or it\'s used on a non-component element.'
+      )
+    } else
+
     // TODO: remove this in 1.0.0
     if (config.interpolate) {
       dir = collectAttrDirective(name, value, options)