Skip to content

Commit

Permalink
feat(warnings): Suggest casting boolean keys
Browse files Browse the repository at this point in the history
Closes vuejs#6126
  • Loading branch information
posva committed Jul 17, 2017
1 parent ac3d1ea commit 0f7f8d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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 0f7f8d9

Please sign in to comment.