refactor(compiler): export isLiteralWhitelisted

This commit is contained in:
三咲智子 Kevin Deng 2024-02-08 20:35:11 +08:00
parent 35b78920c4
commit 0cdc9f20c6
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
3 changed files with 6 additions and 4 deletions

View File

@ -54,6 +54,7 @@ export {
transformExpression, transformExpression,
processExpression, processExpression,
stringifyExpression, stringifyExpression,
isLiteralWhitelisted,
} from './transforms/transformExpression' } from './transforms/transformExpression'
export { export {
buildSlots, buildSlots,

View File

@ -44,7 +44,9 @@ import { parse } from '@babel/parser'
import { IS_REF, UNREF } from '../runtimeHelpers' import { IS_REF, UNREF } from '../runtimeHelpers'
import { BindingTypes } from '../options' import { BindingTypes } from '../options'
const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this') export const isLiteralWhitelisted = /*#__PURE__*/ makeMap(
'true,false,null,this',
)
// a heuristic safeguard to bail constant expressions on presence of // a heuristic safeguard to bail constant expressions on presence of
// likely function invocation and member access // likely function invocation and member access

View File

@ -5,10 +5,11 @@ import {
type SourceLocation, type SourceLocation,
advancePositionWithClone, advancePositionWithClone,
isInDestructureAssignment, isInDestructureAssignment,
isLiteralWhitelisted,
isStaticProperty, isStaticProperty,
walkIdentifiers, walkIdentifiers,
} from '@vue/compiler-dom' } from '@vue/compiler-dom'
import { isGloballyAllowed, makeMap } from '@vue/shared' import { isGloballyAllowed } from '@vue/shared'
import type { Identifier } from '@babel/types' import type { Identifier } from '@babel/types'
import { import {
type CodeFragment, type CodeFragment,
@ -98,8 +99,6 @@ export function genExpression(
} }
} }
const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this')
function genIdentifier( function genIdentifier(
raw: string, raw: string,
{ options, vaporHelper, identifiers }: CodegenContext, { options, vaporHelper, identifiers }: CodegenContext,