@@ -162,10 +162,34 @@ export function transformAttribute(
162162 }
163163}
164164
165+ export function _isBlockedElement (
166+ element : HTMLElement ,
167+ blockClass : string | RegExp ,
168+ blockSelector : string | null ,
169+ ) : boolean {
170+ if ( typeof blockClass === 'string' ) {
171+ if ( element . classList . contains ( blockClass ) ) {
172+ return true ;
173+ }
174+ } else {
175+ element . classList . forEach ( ( className ) => {
176+ if ( blockClass . test ( className ) ) {
177+ return true ;
178+ }
179+ } ) ;
180+ }
181+ if ( blockSelector ) {
182+ return element . matches ( blockSelector )
183+ }
184+
185+ return false ;
186+ }
187+
165188function serializeNode (
166189 n : Node ,
167190 doc : Document ,
168191 blockClass : string | RegExp ,
192+ blockSelector : string | null ,
169193 inlineStylesheet : boolean ,
170194 maskInputOptions : MaskInputOptions = { } ,
171195 recordCanvas : boolean ,
@@ -184,16 +208,7 @@ function serializeNode(
184208 systemId : ( n as DocumentType ) . systemId ,
185209 } ;
186210 case n . ELEMENT_NODE :
187- let needBlock = false ;
188- if ( typeof blockClass === 'string' ) {
189- needBlock = ( n as HTMLElement ) . classList . contains ( blockClass ) ;
190- } else {
191- ( n as HTMLElement ) . classList . forEach ( ( className ) => {
192- if ( blockClass . test ( className ) ) {
193- needBlock = true ;
194- }
195- } ) ;
196- }
211+ const needBlock = _isBlockedElement ( n as HTMLElement , blockClass , blockSelector ) ;
197212 const tagName = getValidTagName ( ( n as HTMLElement ) . tagName ) ;
198213 let attributes : attributes = { } ;
199214 for ( const { name, value } of Array . from ( ( n as HTMLElement ) . attributes ) ) {
@@ -406,6 +421,7 @@ export function serializeNodeWithId(
406421 doc : Document ,
407422 map : idNodeMap ,
408423 blockClass : string | RegExp ,
424+ blockSelector : string | null ,
409425 skipChild = false ,
410426 inlineStylesheet = true ,
411427 maskInputOptions ?: MaskInputOptions ,
@@ -417,6 +433,7 @@ export function serializeNodeWithId(
417433 n ,
418434 doc ,
419435 blockClass ,
436+ blockSelector ,
420437 inlineStylesheet ,
421438 maskInputOptions ,
422439 recordCanvas || false ,
@@ -472,6 +489,7 @@ export function serializeNodeWithId(
472489 doc ,
473490 map ,
474491 blockClass ,
492+ blockSelector ,
475493 skipChild ,
476494 inlineStylesheet ,
477495 maskInputOptions ,
@@ -494,6 +512,7 @@ function snapshot(
494512 maskAllInputsOrOptions : boolean | MaskInputOptions ,
495513 slimDOMSensibleOrOptions : boolean | SlimDOMOptions ,
496514 recordCanvas ?: boolean ,
515+ blockSelector : string | null = null ,
497516) : [ serializedNodeWithId | null , idNodeMap ] {
498517 const idNodeMap : idNodeMap = { } ;
499518 const maskInputOptions : MaskInputOptions =
@@ -543,6 +562,7 @@ function snapshot(
543562 n ,
544563 idNodeMap ,
545564 blockClass ,
565+ blockSelector ,
546566 false ,
547567 inlineStylesheet ,
548568 maskInputOptions ,
0 commit comments