mirror of https://github.com/vuejs/core.git
fix(runtime-core): should allow empty string and 0 as valid vnode key (#807)
This commit is contained in:
parent
b13886b1ba
commit
54a0e93c27
|
@ -38,6 +38,14 @@ describe('vnode', () => {
|
||||||
expect(vnode.props).toBe(null)
|
expect(vnode.props).toBe(null)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('valid vnode keys', () => {
|
||||||
|
let vnode
|
||||||
|
for (const key in ['', '1', -1, 0, 1, null]) {
|
||||||
|
vnode = createVNode('div', { key })
|
||||||
|
expect(vnode.key).toBe(key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
describe('class normalization', () => {
|
describe('class normalization', () => {
|
||||||
test('string', () => {
|
test('string', () => {
|
||||||
const vnode = createVNode('p', { class: 'foo baz' })
|
const vnode = createVNode('p', { class: 'foo baz' })
|
||||||
|
|
|
@ -251,7 +251,7 @@ export function createVNode(
|
||||||
_isVNode: true,
|
_isVNode: true,
|
||||||
type,
|
type,
|
||||||
props,
|
props,
|
||||||
key: (props !== null && props.key) || null,
|
key: props !== null && props.key !== undefined ? props.key : null,
|
||||||
ref: (props !== null && props.ref) || null,
|
ref: (props !== null && props.ref) || null,
|
||||||
scopeId: currentScopeId,
|
scopeId: currentScopeId,
|
||||||
children: null,
|
children: null,
|
||||||
|
|
Loading…
Reference in New Issue