]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(runtime-core): props type support `BigInt` (#2891)
authoredison <daiwei521@126.com>
Wed, 3 Feb 2021 18:25:45 +0000 (02:25 +0800)
committerGitHub <noreply@github.com>
Wed, 3 Feb 2021 18:25:45 +0000 (19:25 +0100)
packages/runtime-core/__tests__/componentProps.spec.ts
packages/runtime-core/src/componentProps.ts

index f75d3c2ebbd419c687c009eb9bc52bcbbc60ad9d..2c072d45aae9eabf39e824c0cc70b5d974303e92 100644 (file)
@@ -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('<div>60000000100000111</div>')
+  })
 })
index 47b0645950595becd841aa82e97fdf55a009e998..03862b21687b08a978cc2fa8fa92188973e63ed2 100644 (file)
@@ -510,7 +510,7 @@ function validateProp(
 }
 
 const isSimpleType = /*#__PURE__*/ makeMap(
-  'String,Number,Boolean,Function,Symbol'
+  'String,Number,Boolean,Function,Symbol,BigInt'
 )
 
 type AssertionResult = {