Skip to content

Commit

Permalink
fix: πŸ› webkit compatibility
Browse files Browse the repository at this point in the history
- resolve issue where webkit ignores styles without type attribute
- resolve issue where webkit
ignores styles with a title attribute
  • Loading branch information
woldtwerk committed Feb 23, 2023
1 parent 906d14f commit d1e203b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/utils/src/customElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ export const adoptStyles = (renderRoot: ShadowRoot | HTMLElement | Document, sty
}
} else {
const style = document.createElement('style')
style.setAttribute('type', 'text/css')
style.textContent = styles.join(' ')

if (renderRoot instanceof HTMLElement) {
// Skip if Styletag exists already.
if (document.querySelectorAll(`style[title=${renderRoot.tagName}]`).length) return
style.title = renderRoot.tagName
if (document.querySelectorAll(`style[id=${renderRoot.tagName}]`).length) return
style.id = renderRoot.tagName
document.head.appendChild(style)
} else {
renderRoot.appendChild(style)
Expand Down

0 comments on commit d1e203b

Please sign in to comment.