Skip to content

Commit

Permalink
fix: include boolean in isPrimitive check (#6127)
Browse files Browse the repository at this point in the history
suppresses key warning for boolean values, closes #6126
  • Loading branch information
posva authored and yyx990803 committed Jul 19, 2017
1 parent 381b485 commit be3dc9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export function isFalse (v: any): boolean %checks {
* Check if value is primitive
*/
export function isPrimitive (value: any): boolean %checks {
return typeof value === 'string' || typeof value === 'number'
return (
typeof value === 'string' ||
typeof value === 'number' ||
typeof value === 'boolean'
)
}

/**
Expand Down
9 changes: 9 additions & 0 deletions test/unit/modules/vdom/create-element.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ describe('create-element', () => {
expect('Avoid using non-primitive value as key').toHaveBeenWarned()
})

it('doesn\'t warn boolean key', () => {
new Vue({
render (h) {
return h('div', { key: true })
}
}).$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 },
Expand Down

0 comments on commit be3dc9c

Please sign in to comment.