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

Take snapshot on comp start & restore on comp end if needed #94

Merged
merged 1 commit into from
Oct 17, 2019

Conversation

fraziermork
Copy link

When the DOM is modified from under react, it can sometimes blow up with an error like Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. when it tries to unmount components whose nodes are no longer present. It isn't sufficient to replace it with an identical node, it needs to be the same one (seems like react stores references somewhere).

To solve this, we take a snapshot of the DOM on compositionstart & store references to all the nodes, then restore the DOM to that state on compositionends that change the text so that react sees what it expects after we update the state and it rerenders.

Based on See ianstormtaylor/slate#2565

@fraziermork fraziermork merged commit 85b9cde into topic-before-input Oct 17, 2019
@fraziermork fraziermork deleted the topic-before-input-dom-snapshot branch October 17, 2019 20:27
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