Skip to content

Commit

Permalink
✨ add some bom variables to white list and optimize runtime get trap …
Browse files Browse the repository at this point in the history
…in sandbox (umijs#1845)

Co-authored-by: zexuan.dzx <[email protected]>
  • Loading branch information
duwonders and zexuan.dzx authored Nov 30, 2021
1 parent 851f853 commit 412113d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/sandbox/proxySandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { SandBox } from '../interfaces';
import { SandBoxType } from '../interfaces';
import { nativeGlobal, nextTask } from '../utils';
import { getTargetValue, setCurrentRunningApp } from './common';
import { getTargetValue, setCurrentRunningApp, getCurrentRunningApp } from './common';

type SymbolTarget = 'target' | 'globalContext';

Expand Down Expand Up @@ -59,6 +59,18 @@ const unscopables = {
Symbol: true,
parseFloat: true,
Float32Array: true,
isNaN: true,
Infinity: true,
Reflect: true,
Float64Array: true,
Function: true,
Map: true,
NaN: true,
Promise: true,
Proxy: true,
Set: true,
parseInt: true,
requestAnimationFrame: true,
};

const useNativeWindowForBindingsProps = new Map<PropertyKey, boolean>([
Expand Down Expand Up @@ -148,7 +160,10 @@ export default class ProxySandbox implements SandBox {

private registerRunningApp(name: string, proxy: Window) {
if (this.sandboxRunning) {
setCurrentRunningApp({ name, window: proxy });
const currentRunningApp = getCurrentRunningApp();
if (!currentRunningApp || currentRunningApp.name !== name) {
setCurrentRunningApp({ name, window: proxy });
}
// FIXME if you have any other good ideas
// remove the mark in next tick, thus we can identify whether it in micro app or not
// this approach is just a workaround, it could not cover all complex cases, such as the micro app runs in the same task context with master in some case
Expand Down

0 comments on commit 412113d

Please sign in to comment.