Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Dom/dynamicCSS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ export function injectCSS(css: string, option: Options = {}) {
return styleNode;
}

const containerCache = new Map<Element, Element>();
const containerCache = new Map<Element, Node & ParentNode>();

export function updateCSS(css: string, key: string, option: Options = {}) {
const container = getContainer(option);

// Get real parent
if (!containerCache.has(container)) {
const placeholderStyle = injectCSS('', option);
const { parentElement } = placeholderStyle;
containerCache.set(container, parentElement);
parentElement.removeChild(placeholderStyle);
const { parentNode } = placeholderStyle;
containerCache.set(container, parentNode);
parentNode.removeChild(placeholderStyle);
}

const existNode = [...containerCache.get(container).children].find(
Expand Down