|
1 | 1 | import { BUILD } from '@app-data'; |
2 | | -import { plt, styles, supportsConstructableStylesheets, supportsShadow, win } from '@platform'; |
| 2 | +import { |
| 3 | + plt, |
| 4 | + styles, |
| 5 | + supportsConstructableStylesheets, |
| 6 | + supportsMutableAdoptedStyleSheets, |
| 7 | + supportsShadow, |
| 8 | + win, |
| 9 | +} from '@platform'; |
3 | 10 | import { CMP_FLAGS, queryNonceMetaTagContent } from '@utils'; |
4 | 11 |
|
5 | 12 | import type * as d from '../declarations'; |
@@ -125,7 +132,11 @@ export const addStyle = (styleContainerNode: any, cmpMeta: d.ComponentRuntimeMet |
125 | 132 | * > If the array needs to be modified, use in-place mutations like push(). |
126 | 133 | * https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets |
127 | 134 | */ |
128 | | - styleContainerNode.adoptedStyleSheets.unshift(stylesheet); |
| 135 | + if (supportsMutableAdoptedStyleSheets) { |
| 136 | + styleContainerNode.adoptedStyleSheets.unshift(stylesheet); |
| 137 | + } else { |
| 138 | + styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets]; |
| 139 | + } |
129 | 140 | } else { |
130 | 141 | /** |
131 | 142 | * If a scoped component is used within a shadow root and constructable stylesheets are |
@@ -171,7 +182,11 @@ export const addStyle = (styleContainerNode: any, cmpMeta: d.ComponentRuntimeMet |
171 | 182 | * > If the array needs to be modified, use in-place mutations like push(). |
172 | 183 | * https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets |
173 | 184 | */ |
174 | | - styleContainerNode.adoptedStyleSheets.push(style); |
| 185 | + if (supportsMutableAdoptedStyleSheets) { |
| 186 | + styleContainerNode.adoptedStyleSheets.push(style); |
| 187 | + } else { |
| 188 | + styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style]; |
| 189 | + } |
175 | 190 | } |
176 | 191 | } |
177 | 192 | return scopeId; |
|
0 commit comments