Skip to content

Commit def3730

Browse files
committed
WIP: An oddity in that it has a .sheet in the mutation , before the load event ... what if the load event has already fired in some browsers (or if the mutation event is delayed)
1 parent cb6d2df commit def3730

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/rrweb/src/record/mutation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,11 @@ export default class MutationBuffer {
669669
value.toLowerCase() === 'stylesheet' &&
670670
m.target.tagName === 'LINK'
671671
) {
672+
if (m.target.sheet) {
673+
console.warn(
674+
'have we missed the onload event due to delayed mutation?',
675+
);
676+
}
672677
this.stylesheetManager.trackLinkElement(
673678
m.target as HTMLLinkElement,
674679
);

packages/rrweb/src/record/stylesheet-manager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class StylesheetManager {
7070
// if <link> is already loaded, it will have .sheet available and that
7171
// will get serialized in the snapshot. The following is for when that doesn't happen
7272
linkEl.addEventListener('load', () => {
73+
console.log('load');
7374
if (!linkEl.sheet) {
7475
return;
7576
}
@@ -80,6 +81,7 @@ export class StylesheetManager {
8081
}
8182
let _cssText = stringifyStylesheet(linkEl.sheet);
8283
if (_cssText) {
84+
console.log('load emit');
8385
_cssText = absoluteToStylesheet(
8486
_cssText,
8587
getHref(linkEl.ownerDocument),

0 commit comments

Comments
 (0)