diff --git a/cypress/e2e/2-the-vm-sandbox/dom.spec.js b/cypress/e2e/2-the-vm-sandbox/dom.spec.js index 8f43e40f9..c8c493276 100644 --- a/cypress/e2e/2-the-vm-sandbox/dom.spec.js +++ b/cypress/e2e/2-the-vm-sandbox/dom.spec.js @@ -18,6 +18,7 @@ describe('whole process vm sandbox set variable', () => { disablePreloadApp: true, sandbox: { snapshot: false, + fixStaticResourceBaseUrl: true, }, protectVariable: ['dynamicScriptOnloadTag', 'dynamicScriptOnerrorTag'], }, diff --git a/cypress/e2e/2-the-vm-sandbox/set-global-variable.spec.js b/cypress/e2e/2-the-vm-sandbox/set-global-variable.spec.js index 231b55b03..51a27157f 100644 --- a/cypress/e2e/2-the-vm-sandbox/set-global-variable.spec.js +++ b/cypress/e2e/2-the-vm-sandbox/set-global-variable.spec.js @@ -21,6 +21,7 @@ describe('whole process vm sandbox set variable', () => { sandbox: { snapshot: false, fixBaseUrl: true, + fixOwnerDocument: true, }, }, }); @@ -70,12 +71,12 @@ describe('whole process vm sandbox set variable', () => { cy.contains('[data-test=title]', ProxyVariableTitle).then(() => { expect( win.document - .querySelector('[data-test=iframe-pre-fix]') + .querySelector('[data-test=iframe-pre-fix-16]') .getAttribute('src'), ).to.equal(`http:${getPublicPath('dev/react16')}iframe`); expect( win.document - .querySelector('[data-test=img-pre-fix]') + .querySelector('[data-test=img-pre-fix-16]') .getAttribute('src'), ).to.equal(`http:${getPublicPath('dev/react16')}img`); }); diff --git a/dev/app-main/src/config.ts b/dev/app-main/src/config.ts index 49c151ba1..007ca09e4 100644 --- a/dev/app-main/src/config.ts +++ b/dev/app-main/src/config.ts @@ -45,6 +45,8 @@ let defaultConfig: RunInfo = { // 并且子应用的查询和添加行为仅会在 DOM 作用域内进行 strictIsolation: false, fixBaseUrl: true, + fixStaticResourceBaseUrl: true, + fixOwnerDocument: true, // 覆盖子应用的执行上下文,使用自定义的执行上下文,例如子应用 localStorage 使用当前主应用 localStorage // 仅在 snapshot: false 时有效 diff --git a/dev/app-react-16/src/sandbox.tsx b/dev/app-react-16/src/sandbox.tsx index 7dad32d37..309b88274 100644 --- a/dev/app-react-16/src/sandbox.tsx +++ b/dev/app-react-16/src/sandbox.tsx @@ -84,12 +84,25 @@ export default function () { add script test onerror
-
document instanceof Document: {String(document instanceof Document)}
-
document.body.parentNode?.parentNode: {String(document === document.body.parentNode?.parentNode)}
+
+ document instanceof Document: {String(document instanceof Document)} +
+
+ document.body.parentNode?.parentNode:{' '} + {String(document === document.body.parentNode?.parentNode)} +
-
-