The original adoptedStylesheet proposal used a frozen array. A follow-up proposal made the array mutable. Chromium 99+ and Firefox 101+ support mutable arrays.
We check if the array is mutable, to ensure backward compat:
|
const supportsMutableAdoptedStyleSheets = |
|
supportsConstructableStyleSheets && |
|
getOwnPropertyDescriptor(document.adoptedStyleSheets, 'length')!.writable; |
We should re-evaluate this in the future once we drop support for older versions of Chromium.