feat(compiler-core): support accessing Error as global in template expressions (#7018)

This commit is contained in:
Eduardo San Martin Morote 2023-11-30 09:39:40 +01:00 committed by GitHub
parent 2a507e32f0
commit bcca475dbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -161,6 +161,14 @@ describe('compiler: expression transform', () => {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [{ content: `Math` }, `.`, { content: `max` }, `(1, 2)`]
})
expect(
(parseWithExpressionTransform(`{{ new Error() }}`) as InterpolationNode)
.content
).toMatchObject({
type: NodeTypes.COMPOUND_EXPRESSION,
children: ['new ', { content: 'Error' }, '()']
})
})
test('should not prefix reserved literals', () => {

View File

@ -3,7 +3,7 @@ import { makeMap } from './makeMap'
const GLOBALS_ALLOWED =
'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console'
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error'
export const isGloballyAllowed = /*#__PURE__*/ makeMap(GLOBALS_ALLOWED)