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

Synchronous 'DOMNodeInserted' DOM Mutation Event is deprecated #766

Closed
cancan101 opened this issue Oct 10, 2023 · 3 comments · Fixed by #767
Closed

Synchronous 'DOMNodeInserted' DOM Mutation Event is deprecated #766

cancan101 opened this issue Oct 10, 2023 · 3 comments · Fixed by #767

Comments

@cancan101
Copy link
Contributor

Seeing this warning from Chrome:

Listener added for a synchronous 'DOMNodeInserted' DOM Mutation Event. This event type is deprecated (https://w3c.github.io/uievents/#legacy-event-types) and work is underway to remove it from this browser. Usage of this event listener will cause performance issues today, and represents a risk of future incompatibility. Consider using MutationObserver instead.

which I think is coming from this line:

$(window.document).on("DOMNodeInserted", function(e) {

there was some discussion about the implementation:

but it may be the case that this needs to be changed sooner than later.

@josteink
Copy link
Collaborator

Thats probably very likely yes. Thanks for the heads up.

I'm going to assume we can fix this somehow by making a non-synchronous handler instead (from the browsers POV). For my extension that's probably fine. I'm going to assume most people using our view_email events (and friends) don't have a hard-dependency on it being synchronous either.

Does anyone have time to look into what the alternate implementation looks like?

@Kravimir
Copy link

The alternative is to use a MutationObserver.

@cancan101
Copy link
Contributor Author

See https://developer.chrome.com/blog/mutation-events-deprecation/#use-mutationobserver-instead for migration suggestion.

I would think these might be able to be merged unless there is a reason one uses body and one uses document: https://github.com/KartikTalwar/gmail.js/blob/080b39455acba8620efbb50a7caf984af8fbdc86/src/gmail.js#L2678C33-L2702

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 a pull request may close this issue.

3 participants