Quellcode durchsuchen

fix: warn slot-scope when used as a prop

Evan You vor 8 Jahren
Ursprung
Commit
8295f71665
2 geänderte Dateien mit 6 neuen und 3 gelöschten Zeilen
  1. 5 2
      src/core/instance/state.js
  2. 1 1
      test/unit/features/options/props.spec.js

+ 5 - 2
src/core/instance/state.js

@@ -18,6 +18,7 @@ import {
   bind,
   noop,
   hasOwn,
+  hyphenate,
   isReserved,
   handleError,
   nativeWatch,
@@ -84,9 +85,11 @@ function initProps (vm: Component, propsOptions: Object) {
     const value = validateProp(key, propsOptions, propsData, vm)
     /* istanbul ignore else */
     if (process.env.NODE_ENV !== 'production') {
-      if (isReservedAttribute(key) || config.isReservedAttr(key)) {
+      const hyphenatedKey = hyphenate(key)
+      if (isReservedAttribute(hyphenatedKey) ||
+          config.isReservedAttr(hyphenatedKey)) {
         warn(
-          `"${key}" is a reserved attribute and cannot be used as component prop.`,
+          `"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`,
           vm
         )
       }

+ 1 - 1
test/unit/features/options/props.spec.js

@@ -501,7 +501,7 @@ describe('Options props', () => {
   })
 
   it('warn reserved props', () => {
-    const specialAttrs = ['key', 'ref', 'slot', 'is']
+    const specialAttrs = ['key', 'ref', 'slot', 'is', 'slot-scope']
     new Vue({
       props: specialAttrs
     })