Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(useStyleTag): allow use of existing node (#2442)
fix(useStyleTag): wrap all DOM updates in condition
  • Loading branch information
jameswragg committed Nov 17, 2022
1 parent 01c2820 commit 944134c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/core/useStyleTag/index.ts
Expand Up @@ -66,17 +66,20 @@ export function useStyleTag(

const cssRef = ref(css)

let stop = () => {}
let stop = () => { }
const load = () => {
if (!document)
return

const el = (document.getElementById(id) || document.createElement('style')) as HTMLStyleElement
el.type = 'text/css'
el.id = id
if (options.media)
el.media = options.media
document.head.appendChild(el)

if (!el.isConnected) {
el.type = 'text/css'
el.id = id
if (options.media)
el.media = options.media
document.head.appendChild(el)
}

if (isLoaded.value)
return
Expand Down

0 comments on commit 944134c

Please sign in to comment.