diff --git a/src/Dom/dynamicCSS.ts b/src/Dom/dynamicCSS.ts index ed2d8973..639b5bcd 100644 --- a/src/Dom/dynamicCSS.ts +++ b/src/Dom/dynamicCSS.ts @@ -75,9 +75,11 @@ export function injectCSS(css: string, option: Options = {}) { ['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER)), ); if (existStyle.length) { - container.insertBefore( + const lastStyle = existStyle[existStyle.length - 1]; + + lastStyle?.parentNode?.insertBefore( styleNode, - existStyle[existStyle.length - 1].nextSibling, + lastStyle.nextSibling, ); return styleNode;