From b4c79dae431e2466243c337b7bea6b5814c20fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=99=88=E5=90=8C=E5=AD=A6?= <10346905+studentchenx@user.noreply.gitee.com> Date: Fri, 19 Aug 2022 17:40:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dstyle=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E8=A2=AB=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=90=86=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/wujie-core/src/effect.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/wujie-core/src/effect.ts b/packages/wujie-core/src/effect.ts index 206c32290..37fdeee6d 100644 --- a/packages/wujie-core/src/effect.ts +++ b/packages/wujie-core/src/effect.ts @@ -72,12 +72,18 @@ function handleStylesheetElementPatch(stylesheetElement: HTMLStyleElement, sandb /** * 劫持处理样式元素的属性 */ + +type stylesheetElement = HTMLStyleElement & { + _hasPatch?: boolean // 判断新增的style标签是否被劫持 +} + function patchStylesheetElement( - stylesheetElement: HTMLStyleElement, + stylesheetElement: stylesheetElement, cssLoader: (code: string, url: string, base: string) => string, sandbox: Wujie, curUrl: string ) { + if( stylesheetElement._hasPatch ) return const innerHTMLDesc = Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML"); const innerTextDesc = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "innerText"); const textContentDesc = Object.getOwnPropertyDescriptor(Node.prototype, "textContent"); @@ -120,6 +126,11 @@ function patchStylesheetElement( } else return rawAppendChild(node); }, }, + _hasPatch: { + get: function () { + return true + } + } }); }