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

Expose roots to afterRefresh hook. #16

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

Conversation

marrs
Copy link

@marrs marrs commented Aug 14, 2024

This allows for direct manipulation of the DOM after you are done rendering it. Useful for focusing elements and other things.

This allows for direct manipulation of the DOM after you are done
rendering it.  Useful for focusing elements and other things.
This patch fixes a bug I experienced when working with contenteditable
elements.

It turns out that deleting the text of a contenteditable element
causes the text node to be removed from the DOM and replaced with
a <br> element instead.

domChanger apparently does not expect text nodes to ever be removed by
the browser, presumably because the contenteditable attribute either
didn't exist or wasn't considered at the time of writing.  So it
continues to store a reference to the text node in its tree after it
has been removed from the DOM.  It will continue to update this node
on subsequent renders, but the user will never see them as the node
is no longer attached.

This patch fixes that issue by not storing any references to text nodes
at all, but instead by altering their contents using their parents'
innerText property.

This should work fine as there is only ever one text node per element
and its value should always be the same as the value of innerText.
@marrs
Copy link
Author

marrs commented Nov 15, 2024

On the off chance you are still maintaining this project, this PR fixes some issues I was having with domChanger while using it recently. The first patch was a useful feature for me, but perhaps you can think of a better way of achieving the same thing. The second patch fixes what I consider to be a bug in domChanger.

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.

1 participant