Skip to content

Commit

Permalink
fix: warn slot-scope when used as a prop
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Oct 4, 2017
1 parent dae173d commit 8295f71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/core/instance/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
bind,
noop,
hasOwn,
hyphenate,
isReserved,
handleError,
nativeWatch,
Expand Down Expand Up @@ -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
)
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/features/options/props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit 8295f71

Please sign in to comment.