diff --git a/src/core/util/props.js b/src/core/util/props.js index 385347bd82..3e57ae8e4f 100644 --- a/src/core/util/props.js +++ b/src/core/util/props.js @@ -145,7 +145,12 @@ function assertType (value: any, type: Function): { let valid const expectedType = getType(type) if (simpleCheckRE.test(expectedType)) { - valid = typeof value === expectedType.toLowerCase() + const t = typeof value + valid = t === expectedType.toLowerCase() + // for primitive wrapper objects + if (!valid && t === 'object') { + valid = value instanceof type + } } else if (expectedType === 'Object') { valid = isPlainObject(value) } else if (expectedType === 'Array') { diff --git a/test/unit/features/options/props.spec.js b/test/unit/features/options/props.spec.js index 818f2af61b..35348d2457 100644 --- a/test/unit/features/options/props.spec.js +++ b/test/unit/features/options/props.spec.js @@ -206,6 +206,17 @@ describe('Options props', () => { expect('Expected Array').toHaveBeenWarned() }) + it('primitive wrapper objects', () => { + /* eslint-disable no-new-wrappers */ + makeInstance(new String('s'), String) + expect(console.error.calls.count()).toBe(0) + makeInstance(new Number(1), Number) + expect(console.error.calls.count()).toBe(0) + makeInstance(new Boolean(true), Boolean) + expect(console.error.calls.count()).toBe(0) + /* eslint-enable no-new-wrappers */ + }) + if (hasSymbol) { it('symbol', () => { makeInstance(Symbol('foo'), Symbol)