@@ -318,6 +318,7 @@ export function needMaskingText(
318318 ? ( node as HTMLElement )
319319 : node . parentElement ;
320320 if ( el === null ) return false ;
321+ if ( maskTextSelector === '*' ) return true ;
321322 if ( typeof maskTextClass === 'string' ) {
322323 if ( checkAncestors ) {
323324 if ( el . closest ( `.${ maskTextClass } ` ) ) return true ;
@@ -500,11 +501,14 @@ function serializeNode(
500501 keepIframeSrcFn,
501502 newlyAddedElement,
502503 rootId,
504+ needsMask,
503505 } ) ;
504506 case n . TEXT_NODE :
505507 return serializeTextNode ( n as Text , {
506508 needsMask,
507509 maskTextFn,
510+ maskInputOptions,
511+ maskInputFn,
508512 rootId,
509513 } ) ;
510514 case n . CDATA_SECTION_NODE :
@@ -535,16 +539,20 @@ function serializeTextNode(
535539 options : {
536540 needsMask : boolean | undefined ;
537541 maskTextFn : MaskTextFn | undefined ;
542+ maskInputOptions : MaskInputOptions ;
543+ maskInputFn : MaskInputFn | undefined ;
538544 rootId : number | undefined ;
539545 } ,
540546) : serializedNode {
541- const { needsMask, maskTextFn, rootId } = options ;
547+ const { needsMask, maskTextFn, maskInputOptions, maskInputFn, rootId } =
548+ options ;
542549 // The parent node may not be a html element which has a tagName attribute.
543550 // So just let it be undefined which is ok in this use case.
544551 const parentTagName = n . parentNode && ( n . parentNode as HTMLElement ) . tagName ;
545552 let textContent = n . textContent ;
546553 const isStyle = parentTagName === 'STYLE' ? true : undefined ;
547554 const isScript = parentTagName === 'SCRIPT' ? true : undefined ;
555+ const isTextarea = parentTagName === 'TEXTAREA' ? true : undefined ;
548556 if ( isStyle && textContent ) {
549557 try {
550558 // try to read style sheet
@@ -574,6 +582,11 @@ function serializeTextNode(
574582 ? maskTextFn ( textContent , n . parentElement )
575583 : textContent . replace ( / [ \S ] / g, '*' ) ;
576584 }
585+ if ( isTextarea && textContent && maskInputOptions . textarea ) {
586+ textContent = maskInputFn
587+ ? maskInputFn ( textContent , n . parentNode as HTMLElement )
588+ : textContent . replace ( / [ \S ] / g, '*' ) ;
589+ }
577590
578591 return {
579592 type : NodeType . Text ,
@@ -601,6 +614,7 @@ function serializeElementNode(
601614 */
602615 newlyAddedElement ?: boolean ;
603616 rootId : number | undefined ;
617+ needsMask ?: boolean ;
604618 } ,
605619) : serializedNode | false {
606620 const {
@@ -616,6 +630,7 @@ function serializeElementNode(
616630 keepIframeSrcFn,
617631 newlyAddedElement = false ,
618632 rootId,
633+ needsMask,
619634 } = options ;
620635 const needBlock = _isBlockedElement ( n , blockClass , blockSelector ) ;
621636 const tagName = getValidTagName ( n ) ;
@@ -673,13 +688,15 @@ function serializeElementNode(
673688 value
674689 ) {
675690 const type = getInputType ( n ) ;
691+
676692 attributes . value = maskInputValue ( {
677693 element : n ,
678694 type,
679695 tagName,
680696 value,
681697 maskInputOptions,
682698 maskInputFn,
699+ needsMask,
683700 } ) ;
684701 } else if ( checked ) {
685702 attributes . checked = checked ;
@@ -1226,7 +1243,7 @@ function snapshot(
12261243 inlineStylesheet ?: boolean ;
12271244 maskAllInputs ?: boolean | MaskInputOptions ;
12281245 maskTextFn ?: MaskTextFn ;
1229- maskInputFn ?: MaskTextFn ;
1246+ maskInputFn ?: MaskInputFn ;
12301247 slimDOM ?: 'all' | boolean | SlimDOMOptions ;
12311248 dataURLOptions ?: DataURLOptions ;
12321249 inlineImages ?: boolean ;
0 commit comments