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

Fix destroy:composer event not being fired #307

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jrhames
Copy link
Contributor

@jrhames jrhames commented Feb 23, 2016

This pull-request fixes two issues:

  • The destroy:composer event is not being fired when the node is removed, as addEventListener only accepts a string as type;
  • The destroy:composer event is not fired if any of it's parents is removed from the document.

Please, note that:
The DOMNodeRemoved has been kept to cover the case where the element is removed from a currently detached parent.

@pulges
Copy link
Contributor

pulges commented Mar 4, 2016

Thanks for finding and taking time to address the issues.
Allthough it is a valid fix of current code I have a doubt merging it to master though. The problem is that mutation events (DOMNodeRemoved and DOMNodeRemovedFromDocument) are labelled as deprecated and browsers support is in process of being removed.
https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Mutation_events

It would be awsome if you could make it using the new mutation observers instead:
https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver

The MutationObserver needs a setTimeout polyfill though if not supported by browser (IE 9-11), but the setTimeout hack is currently used as fallback anyway so it would not be a regression.
https://github.com/Voog/wysihtml/blob/master/src/views/composer.observe.js#L541

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