-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[PM-28079] Add attributes to filter for the mutationObserver #17832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[PM-28079] Add attributes to filter for the mutationObserver #17832
Conversation
|
Claude finished @jholland-livefront's task —— View job Code Review Complete ✓I've thoroughly analyzed this PR and validated the existing reviewer feedback. Here's my comprehensive assessment: 🎯 Overall Assessment: Changes NeededThe PR successfully adds an ✅ What's Working Well
|
| Attribute | Collected | In Filter | Has Handler | Status |
|---|---|---|---|---|
| action | ✓ | ✓ | ✓ | ✅ Complete |
| method | ✓ | ✓ | ✓ | ✅ Complete |
| maxlength | ✓ | ✓ | ✓ | ✅ Complete |
| type | ✓ | ✓ | ✓ | ✅ Complete |
| value | ✓ | ✓ | ✓ | ✅ Complete |
| checked | ✓ | ✓ | ✓ | ✅ Complete |
| disabled | ✓ | ✓ | ✓ | ✅ Complete |
| readonly | ✓ | ✓ | ✓ | ✅ Complete |
| autocomplete | ✓ | ✓ | ✓ | ✅ Complete |
| autocompletetype | ✓ | ✓ | ||
| x-autocompletetype | ✓ | ✓ | ||
| tabindex | ✓ | ✓ | ✓ | ✅ Complete |
| title | ✓ | ✓ | ✓ | ✅ Complete (bug fixed!) |
| rel | ✓ | ✓ | ✓ | ✅ Complete |
| tagname | ✓ | ✓ | ✓ | ✅ Complete |
| data-label | ✓ | ✓ | ✓ | ✅ Complete |
| data-stripe | ✓ | ✓ | ✓ | ✅ Complete |
| id | ✓ | ✓ | ✓ | ✅ Complete |
| name | ✓ | ✓ | ✓ | ✅ Complete |
| class | ✓ | ✓ | ||
| aria-label | ✓ | ✓ | ✓ | ✅ Complete |
| aria-hidden | ✓ | ✓ | ✓ | ✅ Complete |
| aria-disabled | ✓ | ✓ | ✓ | ✅ Complete |
| aria-haspopup | ✓ | ✓ | ✓ | ✅ Complete |
| popover | N/A | ✓ | N/A | ✅ Complete (top-layer handling) |
| popovertarget | N/A | ✓ | N/A | ✅ Complete (top-layer handling) |
| popovertargetaction | N/A | ✓ | N/A | ✅ Complete (top-layer handling) |
| placeholder | ✓ | ❌ | ❌ | ❌ Missing |
🔍 Summary of Required Changes
- Add
placeholderto the filter and handler (if dynamic placeholder changes should be tracked) - Fix form
classattribute handling (either remove from filter or add handler) - Add mutation handlers for legacy autocomplete attributes (for consistency)
💡 Additional Observations
- Excellent: The popover attributes are forward-thinking and handle modern web patterns
- Good: All ARIA attributes are properly included for accessibility tracking
- Performance: The filter should provide the claimed performance improvement by reducing mutation callbacks
✅ Testing Notes
- Tests passing ✓
- Coverage maintained ✓
- BIT tests passing ✓
The changes are functionally sound, just need the attribute completeness issues addressed.
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17832 +/- ##
==========================================
+ Coverage 41.52% 41.67% +0.14%
==========================================
Files 3556 3568 +12
Lines 102951 103442 +491
Branches 15476 15572 +96
==========================================
+ Hits 42754 43110 +356
- Misses 58380 58500 +120
- Partials 1817 1832 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ARIA_HASPOPUP: "aria-haspopup", | ||
| POPOVER: "popover", | ||
| POPOVERTARGET: "popovertarget", | ||
| POPOVERTARGETACTION: "popovertargetaction", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CRITICAL: Missing data-stripe attribute breaks Stripe integration tracking
Details and fix
The data-stripe attribute is collected at line 427 in collect-autofill-content.service.ts:
"data-stripe": this.getPropertyOrAttribute(element, "data-stripe"),And has a mutation handler at line 1360:
"data-stripe": () => updateAttribute("data-stripe"),But it's missing from AUTOFILL_ATTRIBUTES. This means if a Stripe integration dynamically updates the data-stripe attribute on a form field, the MutationObserver won't detect it and autofill data will become stale.
Fix: Add to the constant:
DATA_STRIPE: "data-stripe",Reference: Stripe Elements integration tracking
| READONLY: "readonly", | ||
| AUTOCOMPLETE: "autocomplete", | ||
| TABINDEX: "tabindex", | ||
| TITLE: "title", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Details and fix
The code checks three autocomplete attribute variants (line 457-462 in collect-autofill-content.service.ts):
private getAutoCompleteAttribute(element: ElementWithOpId<FormFieldElement>): string {
return (
this.getPropertyOrAttribute(element, "x-autocompletetype") ||
this.getPropertyOrAttribute(element, "autocompletetype") ||
this.getPropertyOrAttribute(element, "autocomplete")
);
}But only autocomplete is in the filter. The mutation handler at line 1351 calls getAutoCompleteAttribute() which checks all three, but mutations won't be detected for x-autocompletetype or autocompletetype changes since they're not in the filter.
Impact: Legacy sites using x-autocompletetype or autocompletetype (older IE/Safari patterns) won't have their autocomplete changes detected.
Fix: Add these legacy attributes:
X_AUTOCOMPLETETYPE: "x-autocompletetype",
AUTOCOMPLETETYPE: "autocompletetype",While these are legacy attributes, they're explicitly supported by the codebase and should be tracked if a page uses them dynamically.
| CLASS: "class", | ||
| ARIA_LABEL: "aria-label", | ||
| ARIA_HIDDEN: "aria-hidden", | ||
| ARIA_DISABLED: "aria-disabled", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 QUESTION: Should placeholder attribute be tracked for mutations?
Details and context
The placeholder attribute is collected during initial field scanning (line 405 in collect-autofill-content.service.ts):
placeholder: this.getPropertyOrAttribute(element, "placeholder"),However:
- There's no mutation handler for it in
updateAutofillFieldElementData()(lines 1329-1372) - It's not in this attribute filter
Two possible interpretations:
Option A - Intentionally excluded: Placeholder is only used for initial label detection and doesn't need dynamic tracking. If a page changes placeholders dynamically, we don't care because we've already captured the label.
Option B - Missing handler: We should track placeholder changes and add a mutation handler for it.
Question for team: Is placeholder intentionally excluded from mutation tracking, or should we add both the attribute filter entry and a mutation handler?
Context: Placeholder text is used as a fallback label in the autofill system and some modern SPAs (especially progressive web apps) do change placeholders dynamically based on user state.
| ID: "id", | ||
| NAME: "name", | ||
| CLASS: "class", | ||
| ARIA_LABEL: "aria-label", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 QUESTION: Form class attribute tracked but no mutation handler exists
Details and context
The class attribute is in the filter and is collected for forms (line 235 in collect-autofill-content.service.ts):
htmlClass: this.getPropertyOrAttribute(formElement, "class"),It also has a mutation handler for fields (line 1341):
class: () => updateAttribute("htmlClass"),However, there's no handler for form class changes in updateAutofillFormElementData() (lines 1305-1310) - only action, name, id, and method are handled.
Question: Is this intentional, or should we add a class handler to form updates?
// In updateAutofillFormElementData:
const updateActions: Record<string, CallableFunction> = {
action: () => (dataTarget.htmlAction = this.getFormActionAttribute(element)),
name: () => updateAttribute("htmlName"),
id: () => updateAttribute("htmlID"),
method: () => updateAttribute("htmlMethod"),
// Missing: class: () => updateAttribute("htmlClass"),
};If form class changes aren't needed for autofill logic, we could remove it from the filter to reduce mutation observer overhead (the goal of this PR).
|
Overall Assessment: REQUEST CHANGES Critical Issues:
Important Issues:
See inline comments for details and recommended fixes. Note on pre-existing bug (line 1343): While this bug exists in unchanged code, it becomes relevant because this PR enables title mutation tracking. The bug causes title attribute changes to incorrectly overwrite tabindex data. Consider fixing it as part of this PR or in a follow-up. |
Changes in this PR impact the Autofill experience of the browser clientBIT has tested the core experience with these changes and all feature flags disabled. ✅ Fortunately, these BIT tests have passed! 🎉 |
Changes in this PR impact the Autofill experience of the browser clientBIT has tested the core experience with these changes and the feature flag configuration used by ✅ Fortunately, these BIT tests have passed! 🎉 |

🎟️ Tracking
PM-28079
📔 Objective
As part of @jprusik's performance research he determined we can specify the attributes we want to track in the
MutationObserver. I have added 23 attributes we want to track with others being excluded.I implemented a simple
MutationObservercounter locally to get a rough idea of the performance difference. For the Simple Login on webtests.dev theMutationObservercount dropped from 9 to 7 with theattributeFilteradded.I am looking for suggestions any additions or deletions to this attribute list.
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes