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

getCharacterDataChanged() doesn't return removed nodes #14

Open
aartrost opened this issue Jun 15, 2015 · 0 comments
Open

getCharacterDataChanged() doesn't return removed nodes #14

aartrost opened this issue Jun 15, 2015 · 0 comments

Comments

@aartrost
Copy link

Hi Rafael,

First of all I want to thank you for your efforts maintaining this library, it's been integral for detecting changes and maintaining undo history for an inline editor I've been working on.

Recently I ran into a problem where characterDataChanged was empty for a summary in which a text node is first emptied (node.data = "") and then removed from the dom. The resulting summary lists the removal of the node but not the changed characterData ( open console on http://jsfiddle.net/f153aczu/2/ )

This is causing problems with performing undo/redo as the node can be restored, but the text content of the Node is lost. That's why I suggest the following change (aartrost/mutation-summary@7936be7):

if (2 /* STAYED_IN */ !== this.treeChanges.reachabilityChange(target))

->

if ([2 /* STAYED_IN */, 5 /* EXITED */].indexOf(this.treeChanges.reachabilityChange(target)) === -1)

This change will enable the reporting of characterDataChanged for removed nodes, enabling users to properly restore said nodes.

PS: If you're interested I can propose an example based on my custom undo/redo build on top on mutation-summary.

@aartrost aartrost changed the title Return oldCharacterData for removed nodes getCharacterDataChanged() doesn't return removed nodes Jun 15, 2015
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

No branches or pull requests

1 participant