Browse Source

fix: warn slot-scope when used as a prop

dev
Evan You 7 years ago
parent
commit
8295f71665
  1. 7
      src/core/instance/state.js
  2. 2
      test/unit/features/options/props.spec.js

7
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
)
}

2
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
})

Loading…
Cancel
Save