From d3e9872d20e587f257c9e41ace9a4b0b5fc369a6 Mon Sep 17 00:00:00 2001 From: Kuitos Date: Mon, 6 Nov 2023 20:16:06 +0800 Subject: [PATCH] feat(sandbox): use cloneNode api instead of importNode for compatible (#2791) --- .changeset/big-cougars-draw.md | 5 +++++ .../sandbox/src/patchers/dynamicAppend/forStandardSandbox.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/big-cougars-draw.md diff --git a/.changeset/big-cougars-draw.md b/.changeset/big-cougars-draw.md new file mode 100644 index 000000000..9cf0802ea --- /dev/null +++ b/.changeset/big-cougars-draw.md @@ -0,0 +1,5 @@ +--- +"@qiankunjs/sandbox": patch +--- + +feat(sandbox): use cloneNode api instead of importNode for compatible diff --git a/packages/sandbox/src/patchers/dynamicAppend/forStandardSandbox.ts b/packages/sandbox/src/patchers/dynamicAppend/forStandardSandbox.ts index f43d6b11d..ff260d027 100644 --- a/packages/sandbox/src/patchers/dynamicAppend/forStandardSandbox.ts +++ b/packages/sandbox/src/patchers/dynamicAppend/forStandardSandbox.ts @@ -372,7 +372,7 @@ export function patchStandardSandbox( // micro app rendering should wait unit the rebuilding link element is loaded, otherwise it may cause style blink // As one link element will just trigger loaded event once, although we append it multiple times, we need to clone it before every appending - const cloneStyleElement = document.importNode(stylesheetElement) as HTMLLinkElement; + const cloneStyleElement = stylesheetElement.cloneNode(true) as HTMLLinkElement; const deferred = new Deferred(); if (cloneStyleElement.rel === 'stylesheet' && cloneStyleElement.href) { cloneStyleElement.onload = () => deferred.resolve(true);