Skip to content

Commit be3dc9c

Browse files
posvayyx990803
authored andcommitted
fix: include boolean in isPrimitive check (#6127)
suppresses key warning for boolean values, closes #6126
1 parent 381b485 commit be3dc9c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/shared/util.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export function isFalse (v: any): boolean %checks {
2222
* Check if value is primitive
2323
*/
2424
export function isPrimitive (value: any): boolean %checks {
25-
return typeof value === 'string' || typeof value === 'number'
25+
return (
26+
typeof value === 'string' ||
27+
typeof value === 'number' ||
28+
typeof value === 'boolean'
29+
)
2630
}
2731

2832
/**

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

+9
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ describe('create-element', () => {
162162
expect('Avoid using non-primitive value as key').toHaveBeenWarned()
163163
})
164164

165+
it('doesn\'t warn boolean key', () => {
166+
new Vue({
167+
render (h) {
168+
return h('div', { key: true })
169+
}
170+
}).$mount()
171+
expect('Avoid using non-primitive value as key').not.toHaveBeenWarned()
172+
})
173+
165174
it('nested child elements should be updated correctly', done => {
166175
const vm = new Vue({
167176
data: { n: 1 },

0 commit comments

Comments
 (0)