diff --git a/src/sandbox/patchers/dynamicAppend/common.ts b/src/sandbox/patchers/dynamicAppend/common.ts index c301e83..347d012 100644 --- a/src/sandbox/patchers/dynamicAppend/common.ts +++ b/src/sandbox/patchers/dynamicAppend/common.ts @@ -316,8 +316,13 @@ function getNewRemoveChild( case STYLE_TAG_NAME: case LINK_TAG_NAME: { attachedElement = dynamicLinkAttachedInlineStyleMap.get(child as any) || child; + // try to remove the dynamic style sheet - dynamicStyleSheetElements.splice(dynamicStyleSheetElements.indexOf(attachedElement as any), 1); + const dynamicElementIndex = dynamicStyleSheetElements.indexOf(attachedElement as HTMLLinkElement); + if (dynamicElementIndex !== -1) { + dynamicStyleSheetElements.splice(dynamicElementIndex, 1); + } + break; }