diff --git a/apps/browser/src/autofill/services/collect-autofill-content.service.ts b/apps/browser/src/autofill/services/collect-autofill-content.service.ts index fe7ebe61ee..94d84997ee 100644 --- a/apps/browser/src/autofill/services/collect-autofill-content.service.ts +++ b/apps/browser/src/autofill/services/collect-autofill-content.service.ts @@ -980,7 +980,7 @@ export class CollectAutofillContentService implements CollectAutofillContentServ const queueLength = this.mutationsQueue.length; if (!this.domQueryService.pageContainsShadowDomElements()) { - this.domQueryService.checkPageContainsShadowDom(); + this.checkPageContainsShadowDom(); } for (let queueIndex = 0; queueIndex < queueLength; queueIndex++) { @@ -999,6 +999,29 @@ export class CollectAutofillContentService implements CollectAutofillContentServ this.mutationsQueue = []; }; + /** + * Handles checking if the current page contains a ShadowDOM element and + * flags that a re-collection of page details is required if it does. + */ + private checkPageContainsShadowDom() { + this.domQueryService.checkPageContainsShadowDom(); + if (this.domQueryService.pageContainsShadowDomElements()) { + this.flagPageDetailsUpdateIsRequired(); + } + } + + /** + * Triggers several flags that indicate that a collection of page details should + * occur again on a subsequent call after a mutation has been observed in the DOM. + */ + private flagPageDetailsUpdateIsRequired() { + this.domRecentlyMutated = true; + if (this.autofillOverlayContentService) { + this.autofillOverlayContentService.pageDetailsUpdateRequired = true; + } + this.noFieldsFound = false; + } + /** * Processes all mutation records encountered by the mutation observer. * @@ -1023,11 +1046,7 @@ export class CollectAutofillContentService implements CollectAutofillContentServ (this.isAutofillElementNodeMutated(mutation.removedNodes, true) || this.isAutofillElementNodeMutated(mutation.addedNodes)) ) { - this.domRecentlyMutated = true; - if (this.autofillOverlayContentService) { - this.autofillOverlayContentService.pageDetailsUpdateRequired = true; - } - this.noFieldsFound = false; + this.flagPageDetailsUpdateIsRequired(); return; }