File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) 2023 The xterm.js authors. All rights reserved.
3+ * @license MIT
4+ */
5+
16export interface IStyleSheet {
27 dispose : ( ) => void ;
38 setCss : ( value : string ) => void ;
49}
510
6- const createCssStyleSheet = ( ) : IStyleSheet => {
11+ const createCssStyleSheet = ( doc : Document ) : IStyleSheet => {
712 const sheet = new CSSStyleSheet ( ) ;
8- document . adoptedStyleSheets . push ( sheet ) ;
13+ doc . adoptedStyleSheets . push ( sheet ) ;
914 return {
1015 dispose ( ) {
11- const index = document . adoptedStyleSheets . indexOf ( sheet ) ;
12- document . adoptedStyleSheets . splice ( index , 1 ) ;
16+ const index = doc . adoptedStyleSheets . indexOf ( sheet ) ;
17+ doc . adoptedStyleSheets . splice ( index , 1 ) ;
1318 } ,
1419 setCss ( css ) {
1520 sheet . replaceSync ( css ) ;
@@ -18,7 +23,8 @@ const createCssStyleSheet = (): IStyleSheet => {
1823} ;
1924
2025const createStyleElement = ( parent : HTMLElement ) : IStyleSheet => {
21- const element = document . createElement ( 'style' ) ;
26+ const doc = parent . ownerDocument ;
27+ const element = doc . createElement ( 'style' ) ;
2228 parent . append ( element ) ;
2329 return {
2430 dispose ( ) {
@@ -32,7 +38,7 @@ const createStyleElement = (parent: HTMLElement): IStyleSheet => {
3238
3339export const createStyle = ( parent : HTMLElement ) : IStyleSheet => {
3440 try {
35- return createCssStyleSheet ( ) ;
41+ return createCssStyleSheet ( parent . ownerDocument ) ;
3642 } catch {
3743 return createStyleElement ( parent ) ;
3844 }
You can’t perform that action at this time.
0 commit comments