@@ -321,6 +321,7 @@ export function needMaskingText(
321321 ? ( node as HTMLElement )
322322 : node . parentElement ;
323323 if ( el === null ) return false ;
324+ if ( maskTextSelector === '*' ) return true ;
324325 if ( typeof maskTextClass === 'string' ) {
325326 if ( checkAncestors ) {
326327 if ( el . closest ( `.${ maskTextClass } ` ) ) return true ;
@@ -503,11 +504,14 @@ function serializeNode(
503504 keepIframeSrcFn,
504505 newlyAddedElement,
505506 rootId,
507+ needsMask,
506508 } ) ;
507509 case n . TEXT_NODE :
508510 return serializeTextNode ( n as Text , {
509511 needsMask,
510512 maskTextFn,
513+ maskInputOptions,
514+ maskInputFn,
511515 rootId,
512516 } ) ;
513517 case n . CDATA_SECTION_NODE :
@@ -538,16 +542,20 @@ function serializeTextNode(
538542 options : {
539543 needsMask : boolean | undefined ;
540544 maskTextFn : MaskTextFn | undefined ;
545+ maskInputOptions : MaskInputOptions ;
546+ maskInputFn : MaskInputFn | undefined ;
541547 rootId : number | undefined ;
542548 } ,
543549) : serializedNode {
544- const { needsMask, maskTextFn, rootId } = options ;
550+ const { needsMask, maskTextFn, maskInputOptions, maskInputFn, rootId } =
551+ options ;
545552 // The parent node may not be a html element which has a tagName attribute.
546553 // So just let it be undefined which is ok in this use case.
547554 const parentTagName = n . parentNode && ( n . parentNode as HTMLElement ) . tagName ;
548555 let textContent = n . textContent ;
549556 const isStyle = parentTagName === 'STYLE' ? true : undefined ;
550557 const isScript = parentTagName === 'SCRIPT' ? true : undefined ;
558+ const isTextarea = parentTagName === 'TEXTAREA' ? true : undefined ;
551559 if ( isStyle && textContent ) {
552560 try {
553561 // try to read style sheet
@@ -577,6 +585,11 @@ function serializeTextNode(
577585 ? maskTextFn ( textContent , n . parentElement )
578586 : textContent . replace ( / [ \S ] / g, '*' ) ;
579587 }
588+ if ( isTextarea && textContent && maskInputOptions . textarea ) {
589+ textContent = maskInputFn
590+ ? maskInputFn ( textContent , n . parentNode as HTMLElement )
591+ : textContent . replace ( / [ \S ] / g, '*' ) ;
592+ }
580593
581594 return {
582595 type : NodeType . Text ,
@@ -604,6 +617,7 @@ function serializeElementNode(
604617 */
605618 newlyAddedElement ?: boolean ;
606619 rootId : number | undefined ;
620+ needsMask ?: boolean ;
607621 } ,
608622) : serializedNode | false {
609623 const {
@@ -619,6 +633,7 @@ function serializeElementNode(
619633 keepIframeSrcFn,
620634 newlyAddedElement = false ,
621635 rootId,
636+ needsMask,
622637 } = options ;
623638 const needBlock = _isBlockedElement ( n , blockClass , blockSelector ) ;
624639 const tagName = getValidTagName ( n ) ;
@@ -682,6 +697,7 @@ function serializeElementNode(
682697 value,
683698 maskInputOptions,
684699 maskInputFn,
700+ needsMask,
685701 } ) ;
686702 } else if ( checked ) {
687703 attributes . checked = checked ;
@@ -1246,7 +1262,7 @@ function snapshot(
12461262 inlineStylesheet ?: boolean ;
12471263 maskAllInputs ?: boolean | MaskInputOptions ;
12481264 maskTextFn ?: MaskTextFn ;
1249- maskInputFn ?: MaskTextFn ;
1265+ maskInputFn ?: MaskInputFn ;
12501266 slimDOM ?: 'all' | boolean | SlimDOMOptions ;
12511267 dataURLOptions ?: DataURLOptions ;
12521268 inlineImages ?: boolean ;
0 commit comments