From: edison Date: Wed, 3 Feb 2021 18:25:45 +0000 (+0800) Subject: feat(runtime-core): props type support `BigInt` (#2891) X-Git-Tag: v3.0.6~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffd52885453d1621e45dff645ff1101e74ea40b2;p=thirdparty%2Fvuejs%2Fcore.git feat(runtime-core): props type support `BigInt` (#2891) --- diff --git a/packages/runtime-core/__tests__/componentProps.spec.ts b/packages/runtime-core/__tests__/componentProps.spec.ts index f75d3c2ebb..2c072d45aa 100644 --- a/packages/runtime-core/__tests__/componentProps.spec.ts +++ b/packages/runtime-core/__tests__/componentProps.spec.ts @@ -378,4 +378,25 @@ describe('component props', () => { expect(setupProps).toMatchObject(props) expect(renderProxy.$props).toMatchObject(props) }) + + test('props type support BigInt', () => { + const Comp = { + props: { + foo: BigInt + }, + render(this: any) { + return h('div', [this.foo]) + } + } + + const root = nodeOps.createElement('div') + render( + h(Comp, { + foo: BigInt(BigInt(100000111)) + BigInt(2000000000) * BigInt(30000000) + }), + root + ) + + expect(serializeInner(root)).toMatch('
60000000100000111
') + }) }) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 47b0645950..03862b2168 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -510,7 +510,7 @@ function validateProp( } const isSimpleType = /*#__PURE__*/ makeMap( - 'String,Number,Boolean,Function,Symbol' + 'String,Number,Boolean,Function,Symbol,BigInt' ) type AssertionResult = {