File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,21 @@ export default defineConfig(({ command, mode }) => {
80
80
code : `\
81
81
function __insertCSSVueSonner(code) {
82
82
if (!code || typeof document == 'undefined') return
83
- let head = document.head || document.getElementsByTagName('head')[0]
84
- let style = document.createElement('style')
85
- style.type = 'text/css'
86
- head.appendChild(style)
87
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
83
+
84
+ function insertCSS() {
85
+ let head = document.head || document.getElementsByTagName('head')[0]
86
+ if (!head) return
87
+ let style = document.createElement('style')
88
+ style.type = 'text/css'
89
+ head.appendChild(style)
90
+ style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
91
+ }
92
+
93
+ if (document.readyState === 'loading') {
94
+ document.addEventListener('DOMContentLoaded', insertCSS)
95
+ } else {
96
+ insertCSS()
97
+ }
88
98
}\n
89
99
__insertCSSVueSonner(${ JSON . stringify ( cssCodeStr ) } )
90
100
\n ${ code } ` ,
You can’t perform that action at this time.
0 commit comments