File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,11 @@ export const writables: { [key: string]: any } = {
121
121
// 记录初始的
122
122
export const init = new Map < string , boolean > ( ) ;
123
123
124
+ // 需要用到全局的
125
+ export const unscopables : { [ key : string ] : boolean } = {
126
+ RegExp : true ,
127
+ } ;
128
+
124
129
// 复制原有的,防止被前端网页复写
125
130
const descs = Object . getOwnPropertyDescriptors ( global ) ;
126
131
Object . keys ( descs ) . forEach ( ( key ) => {
@@ -193,6 +198,7 @@ export function proxyContext(
193
198
}
194
199
if ( typeof name === "string" && name !== "undefined" ) {
195
200
if ( has ( thisContext , name ) ) {
201
+ // @ts -ignore
196
202
return thisContext [ name ] ;
197
203
}
198
204
if ( context [ name ] ) {
@@ -219,6 +225,8 @@ export function proxyContext(
219
225
}
220
226
return global [ name ] ;
221
227
}
228
+ } else if ( name === Symbol . unscopables ) {
229
+ return unscopables ;
222
230
}
223
231
return undefined ;
224
232
} ,
@@ -238,6 +246,9 @@ export function proxyContext(
238
246
break ;
239
247
}
240
248
if ( typeof name === "string" && name !== "undefined" ) {
249
+ if ( unscopables [ name ] ) {
250
+ return false ;
251
+ }
241
252
if ( has ( thisContext , name ) ) {
242
253
return true ;
243
254
}
@@ -278,6 +289,7 @@ export function proxyContext(
278
289
global [ name ] = val ;
279
290
return true ;
280
291
}
292
+ // @ts -ignore
281
293
thisContext [ name ] = val ;
282
294
return true ;
283
295
} ,
You can’t perform that action at this time.
0 commit comments