Skip to content

Commit

Permalink
WIP: An oddity in that it has a .sheet in the mutation , before the l…
Browse files Browse the repository at this point in the history
…oad event ... what if the load event has already fired in some browsers (or if the mutation event is delayed)
  • Loading branch information
eoghanmurray committed May 22, 2024
1 parent cf330d5 commit d61237e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,11 @@ export default class MutationBuffer {
value.toLowerCase() === 'stylesheet' &&
m.target.tagName === 'LINK'
) {
if (m.target.sheet) {
console.warn(
'have we missed the onload event due to delayed mutation?',
);
}
this.stylesheetManager.trackLinkElement(
m.target as HTMLLinkElement,
);
Expand Down
2 changes: 2 additions & 0 deletions packages/rrweb/src/record/stylesheet-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class StylesheetManager {
// if <link> is already loaded, it will have .sheet available and that
// will get serialized in the snapshot. The following is for when that doesn't happen
linkEl.addEventListener('load', () => {
console.log('load');
if (!linkEl.sheet) {
return;
}
Expand All @@ -80,6 +81,7 @@ export class StylesheetManager {
}
let _cssText = stringifyStylesheet(linkEl.sheet);
if (_cssText) {
console.log('load emit');
_cssText = absoluteToStylesheet(
_cssText,
getHref(linkEl.ownerDocument),
Expand Down

0 comments on commit d61237e

Please sign in to comment.