From be3dc9c6e923248bcf81eb8240dd4f3c168fac59 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 19 Jul 2017 14:27:48 +0200 Subject: [PATCH] fix: include boolean in isPrimitive check (#6127) suppresses key warning for boolean values, closes #6126 --- src/shared/util.js | 6 +++++- test/unit/modules/vdom/create-element.spec.js | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/shared/util.js b/src/shared/util.js index 4ad915a3462..c890d2eddc7 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -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' + ) } /** diff --git a/test/unit/modules/vdom/create-element.spec.js b/test/unit/modules/vdom/create-element.spec.js index 82d6f6bdcb4..e2e8ce27a6d 100644 --- a/test/unit/modules/vdom/create-element.spec.js +++ b/test/unit/modules/vdom/create-element.spec.js @@ -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 },