Skip to content

Commit

Permalink
feat: Guard against missing window.CSSStyleSheet (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea authored Jan 13, 2023
1 parent 07aa1b2 commit 57a2e14
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/rrweb/src/record/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,13 @@ function initStyleSheetObserver(
{ styleSheetRuleCb, mirror, stylesheetManager }: observerParam,
{ win }: { win: IWindow },
): listenerHandler {
if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
// If, for whatever reason, CSSStyleSheet is not available, we skip the observation of stylesheets.
return () => {
// Do nothing
};
}

// eslint-disable-next-line @typescript-eslint/unbound-method
const insertRule = win.CSSStyleSheet.prototype.insertRule;
win.CSSStyleSheet.prototype.insertRule = function (
Expand Down

0 comments on commit 57a2e14

Please sign in to comment.