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: If Node moved to another parent then no any action to delete is … #24

Closed
wants to merge 1 commit into from

Conversation

anthony-redFox
Copy link

…need.

@WebReflection
Copy link
Owner

If Node moved to another parent then no any action to delete is needed

nodes don't move by themselves around, obtrusive libraries might move nodes around though but that violates the purpose of the differ which owns the elements.

this change breaks every library based on domdiff so I am afraid this won't happen.

what you maybe want is to use .remove() instead of parentNode.removeChild() but diffing across two elements makes no sense, also because you can just move all elements at once via fragment.append(...latestNodesInBody).

@anthony-redFox
Copy link
Author

anthony-redFox commented Dec 5, 2022

@WebReflection this is fix for use case - https://codepen.io/anthony-redfox-the-lessful/pen/BaVqLzq?editors=0010
when node was re used in another place. I expected that will be render all nodes (with fix it is works)
foo
bar
baz

The same example with Uhtml - https://codepen.io/anthony-redfox-the-lessful/pen/ExRGVoG?editors=0010
The example execute with script Error!

Can you say what I doing wrong with hyperHtml or Uhtml

@WebReflection
Copy link
Owner

The same example with Uhtml

drop the .for(...) and no error happens

Can you say what I doing wrong with hyperHtml or Uhtml

you want a single node to be simultaneously part of two different parts of the tree ... that can't happen with the DOM, so your option is to not wire the node and just use html tag as is (in uhtml).

Alternatively you can fork this project which is basically dead and use node.remove() instead of parentNode.removeChild(node) within the drop function but you have a fundamental issue with your logic, imho, and that's not worth fixing to me.

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.

None yet

2 participants