UNPKG

@openpass/openpass-js-sdk

Version:
30 lines 1.07 kB
export const injectStylesheetContent = (contents, styleTagId) => { const style = document.createElement("style"); style.innerHTML = contents; style.id = styleTagId; const head = document.getElementsByTagName("head")[0]; head.appendChild(style); }; export const injectStylesheetLinkRef = (href) => { const style = document.createElement("link"); style.href = href; style.rel = "stylesheet"; const head = document.getElementsByTagName("head")[0]; head.appendChild(style); }; export const hasLinkRefContainingHrefText = (text) => { const head = document.getElementsByTagName("head")[0]; const linkElements = head.getElementsByTagName("link"); for (let i = 0; i < linkElements.length; i++) { const link = linkElements[i]; if (link.href.includes(text)) { return true; } } return false; }; export const hasStyleTagWithId = (id) => { const styleTagWithId = document.querySelector(`style[id=${id}]`); return styleTagWithId !== null; }; //# sourceMappingURL=stylesheets.js.map