1- import { logger } from './content/logger'
2- import { injectStyles } from './content/styles'
31import { HandlerRegistry } from '../datamodel/handler-registry'
42import { TextareaRegistry } from '../datamodel/textarea-registry'
3+ import { logger } from './content/logger'
4+ import { injectStyles } from './content/styles'
55
66const handlerRegistry = new HandlerRegistry ( )
77const textareaRegistry = new TextareaRegistry ( )
@@ -31,12 +31,13 @@ function handleMutations(mutations: MutationRecord[]): void {
3131 const element = node as Element
3232 if ( element . tagName === 'TEXTAREA' ) {
3333 initializeMaybeIsPageload ( element as HTMLTextAreaElement )
34- }
35- // Also check for textareas within added subtrees
36- const textareas = element . querySelectorAll ?.( 'textarea' )
37- if ( textareas ) {
38- for ( const textarea of textareas ) {
39- initializeMaybeIsPageload ( textarea )
34+ } else {
35+ // Also check for textareas within added subtrees
36+ const textareas = element . querySelectorAll ?.( 'textarea' )
37+ if ( textareas ) {
38+ for ( const textarea of textareas ) {
39+ initializeMaybeIsPageload ( textarea )
40+ }
4041 }
4142 }
4243 }
@@ -48,12 +49,13 @@ function handleMutations(mutations: MutationRecord[]): void {
4849 const element = node as Element
4950 if ( element . tagName === 'TEXTAREA' ) {
5051 textareaRegistry . unregisterDueToModification ( element as HTMLTextAreaElement )
51- }
52- // Also check for textareas within removed subtrees
53- const textareas = element . querySelectorAll ?.( 'textarea' )
54- if ( textareas ) {
55- for ( const textarea of textareas ) {
56- textareaRegistry . unregisterDueToModification ( textarea )
52+ } else {
53+ // Also check for textareas within removed subtrees
54+ const textareas = element . querySelectorAll ?.( 'textarea' )
55+ if ( textareas ) {
56+ for ( const textarea of textareas ) {
57+ textareaRegistry . unregisterDueToModification ( textarea )
58+ }
5759 }
5860 }
5961 }
@@ -70,7 +72,7 @@ function initializeMaybeIsPageload(textarea: HTMLTextAreaElement) {
7072
7173 logger . debug ( 'activating textarea {}' , textarea )
7274 injectStyles ( )
73-
75+
7476 // Use registry to identify and handle this specific textarea
7577 const textareaInfo = handlerRegistry . identifyTextarea ( textarea )
7678 if ( textareaInfo ) {
0 commit comments