mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
fix(warning): allow symbol as vdom key (#7271)
This commit is contained in:
parent
c0d516c283
commit
bacb911f7d
@ -270,7 +270,7 @@ export function createPatchFunction (backend) {
|
||||
createElm(children[i], insertedVnodeQueue, vnode.elm, null, true)
|
||||
}
|
||||
} else if (isPrimitive(vnode.text)) {
|
||||
nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text))
|
||||
nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ export function isPrimitive (value: any): boolean %checks {
|
||||
return (
|
||||
typeof value === 'string' ||
|
||||
typeof value === 'number' ||
|
||||
// $flow-disable-line
|
||||
typeof value === 'symbol' ||
|
||||
typeof value === 'boolean'
|
||||
)
|
||||
}
|
||||
|
@ -215,6 +215,15 @@ describe('create-element', () => {
|
||||
expect('Avoid using non-primitive value as key').not.toHaveBeenWarned()
|
||||
})
|
||||
|
||||
it('doesn\'t warn symbol key', () => {
|
||||
new Vue({
|
||||
render (h) {
|
||||
return h('div', { key: Symbol('symbol') })
|
||||
}
|
||||
}).$mount()
|
||||
expect('Avoid using non-primitive value as key').not.toHaveBeenWarned()
|
||||
})
|
||||
|
||||
it('nested child elements should be updated correctly', done => {
|
||||
const vm = new Vue({
|
||||
data: { n: 1 },
|
||||
|
Loading…
Reference in New Issue
Block a user