Skip to content

Commit

Permalink
feat(compiler-core): support accessing Error as global in template ex…
Browse files Browse the repository at this point in the history
…pressions (#7018)
  • Loading branch information
posva committed Nov 30, 2023
1 parent 2a507e3 commit bcca475
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/globalsAllowList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit bcca475

Please sign in to comment.