fix(runtime-core): fix kebab-case prop required warning
fix #3495 ref #3363
This commit is contained in:
parent
37c17091fd
commit
2121c32e22
@ -319,6 +319,25 @@ describe('component props', () => {
|
|||||||
expect(`Missing required prop: "num"`).toHaveBeenWarned()
|
expect(`Missing required prop: "num"`).toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #3495
|
||||||
|
test('should not warn required props using kebab-case', async () => {
|
||||||
|
const Comp = {
|
||||||
|
props: {
|
||||||
|
fooBar: { type: String, required: true }
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
return () => null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
render(
|
||||||
|
h(Comp, {
|
||||||
|
'foo-bar': 'hello'
|
||||||
|
}),
|
||||||
|
nodeOps.createElement('div')
|
||||||
|
)
|
||||||
|
expect(`Missing required prop: "fooBar"`).not.toHaveBeenWarned()
|
||||||
|
})
|
||||||
|
|
||||||
test('merging props from mixins and extends', () => {
|
test('merging props from mixins and extends', () => {
|
||||||
let setupProps: any
|
let setupProps: any
|
||||||
let renderProxy: any
|
let renderProxy: any
|
||||||
|
@ -480,7 +480,12 @@ function validateProps(
|
|||||||
for (const key in options) {
|
for (const key in options) {
|
||||||
let opt = options[key]
|
let opt = options[key]
|
||||||
if (opt == null) continue
|
if (opt == null) continue
|
||||||
validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key))
|
validateProp(
|
||||||
|
key,
|
||||||
|
resolvedValues[key],
|
||||||
|
opt,
|
||||||
|
!hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user