diff --git a/packages/rrweb-snapshot/src/css.ts b/packages/rrweb-snapshot/src/css.ts index edeb3470b5..4645deae4f 100644 --- a/packages/rrweb-snapshot/src/css.ts +++ b/packages/rrweb-snapshot/src/css.ts @@ -56,9 +56,9 @@ export interface Node { }; } -export interface NodeWithOptionalRules extends Node { +export interface NodeWithRules extends Node { /** Array of nodes with the types rule, comment and any of the at-rule types. */ - rules?: Array; + rules: Array; } export interface Rule extends Node { @@ -103,7 +103,7 @@ export interface CustomMedia extends Node { /** * The @document at-rule. */ -export interface Document extends NodeWithOptionalRules { +export interface Document extends NodeWithRules { /** The part following @document. */ document?: string; /** The vendor prefix in @document, or undefined if there is none. */ @@ -121,7 +121,7 @@ export interface FontFace extends Node { /** * The @host at-rule. */ -export type Host = NodeWithOptionalRules; +export type Host = NodeWithRules; /** * The @import at-rule. @@ -153,7 +153,7 @@ export interface KeyFrame extends Node { /** * The @media at-rule. */ -export interface Media extends NodeWithOptionalRules { +export interface Media extends NodeWithRules { /** The part following @media. */ media?: string; } @@ -179,7 +179,7 @@ export interface Page extends Node { /** * The @supports at-rule. */ -export interface Supports extends NodeWithOptionalRules { +export interface Supports extends NodeWithRules { /** The part following @supports. */ supports?: string; } @@ -201,10 +201,8 @@ export type AtRule = /** * A collection of rules */ -export interface StyleRules { +export interface StyleRules extends NodeWithRules { source?: string; - /** Array of nodes with the types rule, comment and any of the at-rule types. */ - rules: Array; /** Array of Errors. Errors collected during parsing when option silent is true. */ parsingErrors?: ParserError[]; } diff --git a/packages/rrweb-snapshot/src/rebuild.ts b/packages/rrweb-snapshot/src/rebuild.ts index 9ccce1d8f9..6531cfe339 100644 --- a/packages/rrweb-snapshot/src/rebuild.ts +++ b/packages/rrweb-snapshot/src/rebuild.ts @@ -1,4 +1,4 @@ -import { StyleRules, Rule, Media, NodeWithOptionalRules, parse } from './css'; +import { Rule, Media, NodeWithRules, parse } from './css'; import { serializedNodeWithId, NodeType, @@ -81,9 +81,7 @@ export function adaptCssForReplay(cssText: string, cache: BuildCache): string { const selectors: string[] = []; const medias: string[] = []; - function getSelectors( - rule: StyleRules | Rule | Media | NodeWithOptionalRules, - ) { + function getSelectors(rule: Rule | Media | NodeWithRules) { if ('selectors' in rule && rule.selectors) { rule.selectors.forEach((selector: string) => { if (HOVER_SELECTOR.test(selector)) {