From 8295f716657ffe516f30e84f29ca94f4a0aefabf Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 4 Oct 2017 17:31:58 -0400 Subject: [PATCH] fix: warn slot-scope when used as a prop --- src/core/instance/state.js | 7 +++++-- test/unit/features/options/props.spec.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/instance/state.js b/src/core/instance/state.js index 37f1ab15..f6770325 100644 --- a/src/core/instance/state.js +++ b/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 ) } diff --git a/test/unit/features/options/props.spec.js b/test/unit/features/options/props.spec.js index 35348d24..c92e1ce3 100644 --- a/test/unit/features/options/props.spec.js +++ b/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 })