File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
packages/rrweb-snapshot/src Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -540,6 +540,10 @@ function serializeTextNode(
540
540
} ;
541
541
}
542
542
543
+ function findStylesheet ( doc : Document , href : string ) {
544
+ return Array . from ( doc . styleSheets ) . find ( ( s ) => s . href === href ) ;
545
+ }
546
+
543
547
function serializeElementNode (
544
548
n : HTMLElement ,
545
549
options : {
@@ -592,9 +596,14 @@ function serializeElementNode(
592
596
// remote css
593
597
if ( tagName === 'link' && inlineStylesheet ) {
594
598
//TODO: maybe replace this `.styleSheets` with original one
595
- const stylesheet = Array . from ( doc . styleSheets ) . find ( ( s ) => {
596
- return s . href === ( n as HTMLLinkElement ) . href ;
597
- } ) ;
599
+ const href = ( n as HTMLLinkElement ) . href ;
600
+ let stylesheet = findStylesheet ( doc , href ) ;
601
+ if ( ! stylesheet && href . includes ( '.css' ) ) {
602
+ const rootDomain = window . location . origin ;
603
+ const stylesheetPath = href . replace ( window . location . href , '' ) ;
604
+ const potentialStylesheetHref = rootDomain + '/' + stylesheetPath ;
605
+ stylesheet = findStylesheet ( doc , potentialStylesheetHref ) ;
606
+ }
598
607
let cssText : string | null = null ;
599
608
if ( stylesheet ) {
600
609
cssText = stringifyStylesheet ( stylesheet ) ;
You can’t perform that action at this time.
0 commit comments