Răsfoiți Sursa

feat(compiler-core): support `BigInt` in template (#2900)

edison 5 ani în urmă
părinte
comite
c9f94fa3cf

+ 1 - 1
packages/shared/src/globalsWhitelist.ts

@@ -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)

+ 9 - 0
packages/vue/__tests__/index.spec.ts

@@ -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>')
+  })
 })