You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
yeah, mutating a node set in a callback is gonna give you a bad time. We could copy the nodes but it would be a big perf issue. Can you do your work before or after the morph?
I'm using the morph to compute a diff, so I can't make my changes beforehand, but I can queue them (either with an array outside the callback or with a setTimeout call). The ergonomics are worse, but it's functional.
At a glance, the behavior traces back to here, which seems to be the only place where the oldNode pointer is updated after the call to beforeNodeMorphed, which makes it seem as though this behavior could be allowed with minimal risk or effort.
(The next-best option for allowing mutations in that callback is probably using Array.from to create "snapshots" of each Node's childNodes and iterate through them by index, though that would require a more substantial refactor and add some processor and memory overhead.)
I stumbled onto this while I was building an HTML change auditing interface.
If I have a node containing multiple children…
… and a target markup that outputs the same children, with different content…
… and a
beforeNodeMorphed
callback that changes changes the number of children…… then one or more of Idiomorph's internal iterators seem to get confused, leading to skipped or duplicated content.
The text was updated successfully, but these errors were encountered: