]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(compiler-core): support `BigInt` in template (#2900)
authoredison <daiwei521@126.com>
Wed, 3 Feb 2021 18:28:46 +0000 (02:28 +0800)
committerGitHub <noreply@github.com>
Wed, 3 Feb 2021 18:28:46 +0000 (19:28 +0100)
packages/shared/src/globalsWhitelist.ts
packages/vue/__tests__/index.spec.ts

index c6347bf29905fec88abb5e71292e40836a340a67..f383450c88d9037bf3726b594ce208b67fdb23bd 100644 (file)
@@ -3,6 +3,6 @@ import { makeMap } from './makeMap'
 const GLOBALS_WHITE_LISTED =
   'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
   'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
-  'Object,Boolean,String,RegExp,Map,Set,JSON,Intl'
+  'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt'
 
 export const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED)
index b425e5de7aea342086a5489d5d63746a85f64dc8..99e3a63a6ae0d715e8cc6ef4dad785d77847dd1a 100644 (file)
@@ -292,4 +292,13 @@ describe('compiler + runtime integration', () => {
     createApp(App).mount(container)
     expect(EMPTY_ARR.length).toBe(0)
   })
+
+  test('BigInt support', () => {
+    const app = createApp({
+      template: `<div>{{ BigInt(BigInt(100000111)) + BigInt(2000000000n) * 30000000n }}</div>`
+    })
+    const root = document.createElement('div')
+    app.mount(root)
+    expect(root.innerHTML).toBe('<div>60000000100000111</div>')
+  })
 })