Skip to content

Commit 0416839

Browse files
committed
improve camelCase prop warning message
1 parent c6ab2e0 commit 0416839

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/core/util/debug.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ if (process.env.NODE_ENV !== 'production') {
3232
if (vm.$root === vm) {
3333
return '<Root>'
3434
}
35-
let name = vm._isVue
36-
? vm.$options.name || vm.$options._componentTag
37-
: vm.name
35+
let name = typeof vm === 'function' && vm.options
36+
? vm.options.name
37+
: vm._isVue
38+
? vm.$options.name || vm.$options._componentTag
39+
: vm.name
3840

3941
const file = vm._isVue && vm.$options.__file
4042
if (!name && file) {

src/core/vdom/create-component.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
isObject,
1111
hasOwn,
1212
hyphenate,
13-
validateProp
13+
validateProp,
14+
formatComponentName
1415
} from '../util/index'
1516

1617
import {
@@ -293,8 +294,11 @@ function extractProps (data: VNodeData, Ctor: Class<Component>): ?Object {
293294
attrs && attrs.hasOwnProperty(keyInLowerCase)
294295
) {
295296
warn(
296-
`HTML attributes are case-insensitive. camelCased prop names need ` +
297-
`to use their kebab-case equivalents. ${key} should be ${altKey}.`
297+
`Prop "${keyInLowerCase}" is not declared in component ` +
298+
`${formatComponentName(Ctor)}. Note that HTML attributes are ` +
299+
`case-insensitive and camelCased props need to use their kebab-case ` +
300+
`equivalents when using in-DOM templates. You should probably use ` +
301+
`"${altKey}" instead of "${key}".`
298302
)
299303
}
300304
}

test/unit/features/component/component.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ describe('Component', () => {
272272
}
273273
}).$mount()
274274
expect(
275-
'HTML attributes are case-insensitive. camelCased prop names need ' +
276-
'to use their kebab-case equivalents. someCollection should be some-collection.'
275+
'You should probably use "some-collection" instead of "someCollection".'
277276
).toHaveBeenWarned()
278277
})
279278

0 commit comments

Comments
 (0)