Skip to content

Commit e3e50e3

Browse files
committed
Revert "fix: append stylesheet only"
This reverts commit a2a88ec.
1 parent d0411b3 commit e3e50e3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tsup.config.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ const injectFunc = `
44
function injectStyle(css) {
55
if (!css || typeof document === 'undefined') return
66
7-
let head = document.head || document.getElementsByTagName('head')[0]
8-
let style = document.createElement('style')
7+
const head = document.head || document.getElementsByTagName('head')[0]
8+
const style = document.createElement('style')
9+
style.type = 'text/css'
10+
11+
if(head.firstChild) {
12+
head.insertBefore(style, head.firstChild)
13+
} else {
14+
head.appendChild(style)
15+
}
916
10-
head.appendChild(style)
11-
style.appendChild(document.createTextNode(css))
17+
if(style.styleSheet) {
18+
style.styleSheet.cssText = css
19+
} else {
20+
style.appendChild(document.createTextNode(css))
21+
}
1222
}
1323
`;
1424

0 commit comments

Comments
 (0)