Ver Fonte

revert: revert prop object validation

close #7279
Evan You há 8 anos atrás
pai
commit
01c07503bf
2 ficheiros alterados com 0 adições e 40 exclusões
  1. 0 23
      src/core/util/options.js
  2. 0 17
      test/unit/features/options/props.spec.js

+ 0 - 23
src/core/util/options.js

@@ -292,9 +292,6 @@ function normalizeProps (options: Object, vm: ?Component) {
     for (const key in props) {
       val = props[key]
       name = camelize(key)
-      if (process.env.NODE_ENV !== 'production' && isPlainObject(val)) {
-        validatePropObject(name, val, vm)
-      }
       res[name] = isPlainObject(val)
         ? val
         : { type: val }
@@ -309,26 +306,6 @@ function normalizeProps (options: Object, vm: ?Component) {
   options.props = res
 }
 
-/**
- * Validate whether a prop object keys are valid.
- */
-const propOptionsRE = /^(type|default|required|validator)$/
-
-function validatePropObject (
-  propName: string,
-  prop: Object,
-  vm: ?Component
-) {
-  for (const key in prop) {
-    if (!propOptionsRE.test(key)) {
-      warn(
-        `Invalid key "${key}" in validation rules object for prop "${propName}".`,
-        vm
-      )
-    }
-  }
-}
-
 /**
  * Normalize all injections into Object-based format
  */

+ 0 - 17
test/unit/features/options/props.spec.js

@@ -513,23 +513,6 @@ describe('Options props', () => {
     })
   })
 
-  it('should warn about misspelled keys in prop validation object', () => {
-    new Vue({
-      template: '<test></test>',
-      components: {
-        test: {
-          template: '<div></div>',
-          props: {
-            value: { reqquired: true },
-            count: { deafult: 1 }
-          }
-        }
-      }
-    }).$mount()
-    expect(`Invalid key "reqquired" in validation rules object for prop "value".`).toHaveBeenWarned()
-    expect(`Invalid key "deafult" in validation rules object for prop "count".`).toHaveBeenWarned()
-  })
-
   it('should not trigger re-render on non-changed inline literals', done => {
     const updated = jasmine.createSpy('updated')
     const vm = new Vue({