Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commitbacb911

Browse files
HerringtonDarkholmeyyx990803
authored andcommitted
fix(warning): allow symbol as vdom key (vuejs#7271)
1 parentc0d516c commitbacb911

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

‎src/core/vdom/patch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export function createPatchFunction (backend) {
270270
createElm(children[i],insertedVnodeQueue,vnode.elm,null,true)
271271
}
272272
}elseif(isPrimitive(vnode.text)){
273-
nodeOps.appendChild(vnode.elm,nodeOps.createTextNode(vnode.text))
273+
nodeOps.appendChild(vnode.elm,nodeOps.createTextNode(String(vnode.text)))
274274
}
275275
}
276276

‎src/shared/util.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export function isPrimitive (value: any): boolean %checks {
2727
return(
2828
typeofvalue==='string'||
2929
typeofvalue==='number'||
30+
// $flow-disable-line
31+
typeofvalue==='symbol'||
3032
typeofvalue==='boolean'
3133
)
3234
}

‎test/unit/modules/vdom/create-element.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ describe('create-element', () => {
215215
expect('Avoid using non-primitive value as key').not.toHaveBeenWarned()
216216
})
217217

218+
it('doesn\'t warn symbol key',()=>{
219+
newVue({
220+
render(h){
221+
returnh('div',{key:Symbol('symbol')})
222+
}
223+
}).$mount()
224+
expect('Avoid using non-primitive value as key').not.toHaveBeenWarned()
225+
})
226+
218227
it('nested child elements should be updated correctly',done=>{
219228
constvm=newVue({
220229
data:{n:1},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp