Skip to content

Comments

Fix destroy:composer event not being fired#307

Open
jrhames wants to merge 2 commits intoVoog:masterfrom
onsigntv:noderemoval-fix
Open

Fix destroy:composer event not being fired#307
jrhames wants to merge 2 commits intoVoog:masterfrom
onsigntv:noderemoval-fix

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