Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: Guard against missing window.CSSStyleSheet
  • Loading branch information
mydea committed Jan 10, 2023
commit f426d3e4785776e96d3711dfd4b97ccde7532d89
7 changes: 7 additions & 0 deletions packages/rrweb/src/record/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,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