Skip to content

Commit c7a0776

Browse files
committed
Need to check type before querying selectorText property - also good as it means we only try to fix colons at the leaf level
1 parent 6eb2e5a commit c7a0776

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/rrweb-snapshot/src/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ export function getCssRuleString(rule: CSSRule): string {
7575
} catch {
7676
// ignore
7777
}
78-
}
79-
if (rule.selectorText.includes(':')) {
78+
} else if (isCSSStyleRule(rule) && rule.selectorText.includes(':')) {
8079
// Safari does not escape selectors with : properly
8180
cssStringified = fixSafariColons(cssStringified);
8281
}
@@ -93,6 +92,10 @@ export function isCSSImportRule(rule: CSSRule): rule is CSSImportRule {
9392
return 'styleSheet' in rule;
9493
}
9594

95+
export function isCSSStyleRule(rule: CSSRule): rule is CSSStyleRule {
96+
return 'selectorText' in rule;
97+
}
98+
9699
export class Mirror implements IMirror<Node> {
97100
private idNodeMap: idNodeMap = new Map();
98101
private nodeMetaMap: nodeMetaMap = new WeakMap();

0 commit comments

Comments
 (0)