From a95e612b252ae59eaf56e0b8ddba66948d4ac20e Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 26 May 2023 11:07:13 -0500 Subject: [PATCH] chore: rename globals allow list close #8416 --- .../compiler-core/src/transforms/transformExpression.ts | 6 +++--- packages/runtime-core/src/componentPublicInstance.ts | 4 ++-- .../shared/src/{globalsWhitelist.ts => globalsAllowList.ts} | 4 ++-- packages/shared/src/index.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename packages/shared/src/{globalsWhitelist.ts => globalsAllowList.ts} (70%) diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index 3e75923d0d4..eab6b237f13 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -25,7 +25,7 @@ import { } from '../babelUtils' import { advancePositionWithClone, isSimpleIdentifier } from '../utils' import { - isGloballyWhitelisted, + isGloballyAllowed, makeMap, hasOwn, isString, @@ -225,7 +225,7 @@ export function processExpression( if (isSimpleIdentifier(rawExp)) { const isScopeVarReference = context.identifiers[rawExp] - const isAllowedGlobal = isGloballyWhitelisted(rawExp) + const isAllowedGlobal = isGloballyAllowed(rawExp) const isLiteral = isLiteralWhitelisted(rawExp) if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) { // const bindings exposed from setup can be skipped for patching but @@ -358,7 +358,7 @@ export function processExpression( function canPrefix(id: Identifier) { // skip whitelisted globals - if (isGloballyWhitelisted(id.name)) { + if (isGloballyAllowed(id.name)) { return false } // special case for webpack compilation diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index 78a9acd147f..dc575aafff9 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -9,7 +9,7 @@ import { instanceWatch, WatchOptions, WatchStopHandle } from './apiWatch' import { EMPTY_OBJ, hasOwn, - isGloballyWhitelisted, + isGloballyAllowed, NOOP, extend, isString, @@ -511,7 +511,7 @@ export const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend( return PublicInstanceProxyHandlers.get!(target, key, target) }, has(_: ComponentRenderContext, key: string) { - const has = key[0] !== '_' && !isGloballyWhitelisted(key) + const has = key[0] !== '_' && !isGloballyAllowed(key) if (__DEV__ && !has && PublicInstanceProxyHandlers.has!(_, key)) { warn( `Property ${JSON.stringify( diff --git a/packages/shared/src/globalsWhitelist.ts b/packages/shared/src/globalsAllowList.ts similarity index 70% rename from packages/shared/src/globalsWhitelist.ts rename to packages/shared/src/globalsAllowList.ts index 9485a41dafa..c303be11d4c 100644 --- a/packages/shared/src/globalsWhitelist.ts +++ b/packages/shared/src/globalsAllowList.ts @@ -1,8 +1,8 @@ import { makeMap } from './makeMap' -const GLOBALS_WHITE_LISTED = +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' -export const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED) +export const isGloballyAllowed = /*#__PURE__*/ makeMap(GLOBALS_ALLOWED) diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 2e7292f0eac..11580a06435 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -3,7 +3,7 @@ export * from './general' export * from './patchFlags' export * from './shapeFlags' export * from './slotFlags' -export * from './globalsWhitelist' +export * from './globalsAllowList' export * from './codeframe' export * from './normalizeProp' export * from './domTagConfig'