diff --git a/packages/core/src/sheet.js b/packages/core/src/sheet.js index b6ffbba0..27542e72 100644 --- a/packages/core/src/sheet.js +++ b/packages/core/src/sheet.js @@ -25,6 +25,15 @@ const isSheetAccessible = (/** @type {CSSStyleSheet} */ sheet) => { } } +/** Whether `root` supports constructable stylesheets (`new CSSStyleSheet()` + `adoptedStyleSheets`). */ +const supportsConstructedStylesheets = (/** @type {DocumentOrShadowRoot} */ root) => { + try { + return Array.isArray(Object(root).adoptedStyleSheets) && typeof CSSStyleSheet !== 'undefined' && 'replaceSync' in CSSStyleSheet.prototype + } catch (e) { + return false + } +} + export const createSheet = (/** @type {DocumentOrShadowRoot} */ root) => { /** @type {SheetGroup} Object hosting the hydrated stylesheet. */ let groupSheet @@ -71,8 +80,8 @@ export const createSheet = (/** @type {DocumentOrShadowRoot} */ root) => { } } - /** @type {StyleSheetList} */ - const sheets = Object(root).styleSheets || [] + /** @type {(CSSStyleSheet)[]} Stylesheets from `