🐛 compatible with old browser like chrome55 (#2427)
This commit is contained in:
parent
f4425d1fba
commit
cf7e6b4eb8
|
|
@ -42,12 +42,14 @@ export function createSandboxContainer(
|
|||
) {
|
||||
let sandbox: SandBox;
|
||||
if (window.Proxy) {
|
||||
sandbox = useLooseSandbox ? new LegacySandbox(appName, globalContext) : new ProxySandbox(appName, globalContext);
|
||||
sandbox = useLooseSandbox
|
||||
? new LegacySandbox(appName, globalContext)
|
||||
: new ProxySandbox(appName, globalContext, { speedy: !!speedySandBox });
|
||||
} else {
|
||||
sandbox = new SnapshotSandbox(appName);
|
||||
}
|
||||
|
||||
// some side effect could be be invoked while bootstrapping, such as dynamic stylesheet injection with style-loader, especially during the development phase
|
||||
// some side effect could be invoked while bootstrapping, such as dynamic stylesheet injection with style-loader, especially during the development phase
|
||||
const bootstrappingFreers = patchAtBootstrapping(
|
||||
appName,
|
||||
elementGetter,
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ export function patchHTMLDynamicAppendPrototypeFunctions(
|
|||
isInvokedByMicroApp: (element: HTMLElement) => boolean,
|
||||
containerConfigGetter: (element: HTMLElement) => ContainerConfig,
|
||||
) {
|
||||
// Just overwrite it while it have not been overwrite
|
||||
// Just overwrite it while it have not been overwritten
|
||||
if (
|
||||
HTMLHeadElement.prototype.appendChild === rawHeadAppendChild &&
|
||||
HTMLBodyElement.prototype.appendChild === rawBodyAppendChild &&
|
||||
|
|
@ -424,7 +424,7 @@ export function patchHTMLDynamicAppendPrototypeFunctions(
|
|||
}) as typeof rawHeadInsertBefore;
|
||||
}
|
||||
|
||||
// Just overwrite it while it have not been overwrite
|
||||
// Just overwrite it while it have not been overwritten
|
||||
if (
|
||||
HTMLHeadElement.prototype.removeChild === rawHeadRemoveChild &&
|
||||
HTMLBodyElement.prototype.removeChild === rawBodyRemoveChild
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ const useNativeWindowForBindingsProps = new Map<PropertyKey, boolean>([
|
|||
['mockDomAPIInBlackList', process.env.NODE_ENV === 'test'],
|
||||
]);
|
||||
|
||||
function createFakeWindow(globalContext: Window) {
|
||||
function createFakeWindow(globalContext: Window, speedy: boolean) {
|
||||
// map always has the fastest performance in has check scenario
|
||||
// see https://jsperf.com/array-indexof-vs-set-has/23
|
||||
const propertiesWithGetter = new Map<PropertyKey, boolean>();
|
||||
|
|
@ -111,6 +111,8 @@ function createFakeWindow(globalContext: Window) {
|
|||
p === 'parent' ||
|
||||
p === 'self' ||
|
||||
p === 'window' ||
|
||||
// window.document is overwriting in speedy mode
|
||||
(p === 'document' && speedy) ||
|
||||
(inTest && (p === mockTop || p === mockSafariTop))
|
||||
) {
|
||||
descriptor.configurable = true;
|
||||
|
|
@ -193,13 +195,14 @@ export default class ProxySandbox implements SandBox {
|
|||
{};
|
||||
globalContext: typeof window;
|
||||
|
||||
constructor(name: string, globalContext = window) {
|
||||
constructor(name: string, globalContext = window, opts?: { speedy: boolean }) {
|
||||
this.name = name;
|
||||
this.globalContext = globalContext;
|
||||
this.type = SandBoxType.Proxy;
|
||||
const { updatedValueSet } = this;
|
||||
const { speedy } = opts || {};
|
||||
|
||||
const { fakeWindow, propertiesWithGetter } = createFakeWindow(globalContext);
|
||||
const { fakeWindow, propertiesWithGetter } = createFakeWindow(globalContext, !!speedy);
|
||||
|
||||
const descriptorTargetMap = new Map<PropertyKey, SymbolTarget>();
|
||||
const hasOwnProperty = (key: PropertyKey) => fakeWindow.hasOwnProperty(key) || globalContext.hasOwnProperty(key);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user