Skip to content

Commit

Permalink
fix: dropped styles on route transition (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Jun 25, 2024
1 parent 0ae59ce commit 2f2adf3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
25 changes: 24 additions & 1 deletion patches/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ index ea868845c4fad3276aa8e5f74abfd3568b466d11..965505de44975e718d431a4e9a62e753

export { WorkerFactory as default };
diff --git a/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js b/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
index da2c103fe6b1408a5996f0eb3bf047571e434cc2..3b34097a089791bd1043f313dcab9ad4c3733830 100644
index da2c103fe6b1408a5996f0eb3bf047571e434cc2..f5b060c7e0728a3e2c6cf62b01d97282f2484ac3 100644
--- a/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
+++ b/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
@@ -91,11 +91,21 @@ class CanvasManager {
Expand Down Expand Up @@ -223,3 +223,26 @@ index da2c103fe6b1408a5996f0eb3bf047571e434cc2..3b34097a089791bd1043f313dcab9ad4
dataURLOptions: options.dataURLOptions,
}, [bitmap]);
}));
diff --git a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
index 0fc7d4bcafc9be822347f9437658478fd77d9972..a2400dbd745664cc94335f9a0d04bb52af91ee13 100644
--- a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
+++ b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
@@ -641,9 +641,17 @@ function serializeElementNode(n, options) {
}
}
if (tagName === 'link' && inlineStylesheet) {
- const stylesheet = Array.from(doc.styleSheets).find((s) => {
+ let stylesheet = Array.from(doc.styleSheets).find((s) => {
return s.href === n.href;
});
+ if (!stylesheet && n.href.contains('.css')) {
+ const rootDomain = window.location.origin
+ const stylesheetPath = n.href.replace(window.location.href, '')
+ const potentialStylesheetHref = rootDomain + '/' + stylesheetPath
+ stylesheet = Array.from(doc.styleSheets).find((s) => {
+ return s.href === potentialStylesheetHref;
+ });
+ }
let cssText = null;
if (stylesheet) {
cssText = stringifyStylesheet(stylesheet);
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f2adf3

Please sign in to comment.