Skip to content
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

Support events on buttons/links/forms in ShadowDOMs #1351

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

jethron
Copy link
Contributor

@jethron jethron commented Oct 4, 2024

When DOM events on elements within Custom Components/ShadowRoots trigger against the document, the target is set to the Custom Element/shadow host rather than the actual element that caused the event.

This change adds support to the from/button/link tracking plugins to detect when this occurs, and use the first element from the Event's composedPath instead of the target. This enables them to see the actual even target and fire correctly in this scenario.

For the Form tracker, only focus events are considered composed, so change and submit events don't actually get reported outside the shadow DOM. As a workaround, when the focus events occur, if enabled the change/submit event listeners are bound directly to the form (or field if it has no associated form) rather than just the document.

Copy link

bundlemon bot commented Oct 4, 2024

BundleMon

Files added (6)
Status Path Size Limits
trackers/javascript-tracker/dist/sp.js
+24.32KB 30KB / +10%
libraries/browser-tracker-core/dist/index.mod
ule.js
+23.41KB 25KB / +10%
libraries/tracker-core/dist/index.module.js
+19.12KB 20KB / +10%
trackers/browser-tracker/dist/index.umd.min.j
s
+17.24KB 20KB / +10%
trackers/javascript-tracker/dist/sp.lite.js
+17.18KB 20KB / +10%
trackers/browser-tracker/dist/index.module.js
+3.49KB 5KB / +10%

Total files change +104.75KB 0%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history

@jethron jethron changed the title Support clicks on buttons/links in ShadowDOMs Support events on buttons/links/forms in ShadowDOMs Oct 8, 2024
Copy link
Contributor

@matus-tomlein matus-tomlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@jethron jethron merged commit 759f88d into snowplow:release/4.0.0 Oct 9, 2024
2 checks passed
@jethron jethron deleted the shadow-clicks branch October 9, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants