Skip to content

Commit a2bae80

Browse files
committed
add guard to calling requestAnimationFrame in Stylesheet
This fix is for ssr-tests.
1 parent f64e53f commit a2bae80

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/merge-styles/src/Stylesheet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const ADOPTED_STYLESHEETS = '__mergeStylesAdoptedStyleSheets__';
114114
*/
115115
const REUSE_STYLE_NODE = typeof navigator !== 'undefined' && /rv:11.0/.test(navigator.userAgent);
116116

117-
const SUPPORTS_CONSTRUCTIBLE_STYLESHEETS = 'CSSStyleSheet' in window;
117+
const SUPPORTS_CONSTRUCTIBLE_STYLESHEETS = typeof window !== 'undefined' && 'CSSStyleSheet' in window;
118118

119119
export type AdoptableStylesheet = {
120120
fluentSheet: Stylesheet;
@@ -195,7 +195,7 @@ export class Stylesheet {
195195
global[ADOPTED_STYLESHEETS] = new EventMap();
196196
}
197197
global[ADOPTED_STYLESHEETS]!.set(stylesheetKey, stylesheet);
198-
requestAnimationFrame(() => {
198+
(global as Window).requestAnimationFrame?.(() => {
199199
global[ADOPTED_STYLESHEETS]!.raise('add-sheet', { key: stylesheetKey, sheet: stylesheet });
200200
});
201201
}

0 commit comments

Comments
 (0)