File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ function getOrder(prepend?: Prepend): AppendType {
46
46
*/
47
47
function findStyles ( container : ContainerType ) {
48
48
return Array . from (
49
- ( containerCache . get ( container ) || container ) . children ,
49
+ ( containerCache . get ( container ) || container ) ? .children ?? [ ] ,
50
50
) . filter ( node => node . tagName === 'STYLE' ) as HTMLStyleElement [ ] ;
51
51
}
52
52
@@ -66,7 +66,7 @@ export function injectCSS(css: string, option: Options = {}) {
66
66
styleNode . innerHTML = css ;
67
67
68
68
const container = getContainer ( option ) ;
69
- const { firstChild } = container ;
69
+ const firstChild = container ?. firstChild ;
70
70
71
71
if ( prepend ) {
72
72
// If is queue `prepend`, it will prepend first style and then append rest style
@@ -85,7 +85,9 @@ export function injectCSS(css: string, option: Options = {}) {
85
85
}
86
86
87
87
// Use `insertBefore` as `prepend`
88
- container . insertBefore ( styleNode , firstChild ) ;
88
+ if ( firstChild ) {
89
+ container . insertBefore ( styleNode , firstChild ) ;
90
+ }
89
91
} else {
90
92
container . appendChild ( styleNode ) ;
91
93
}
You can’t perform that action at this time.
0 commit comments