-
Notifications
You must be signed in to change notification settings - Fork 47
Fix issue with outerHTML morphing an IDed node that gets moved #126
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
Conversation
|
Hmm, looks like this isn't actually as bad as it appears. The @MichaelWest22 would you mind applying your keen perspective to this issue? My last commit marks three tests with |
|
We found it was possible to remove the duck tape solution earlier which I think would likely resolve this issue properly. But the reversion of the duck tape solution i proposed had a drawback that by default it would allow the mutation of the source nodes which was always the way idiomorph 0.4.0 and older worked anyway. But in 0.7.0+ with the duct tape solution it no longer mutates the source nodes as it normally did before. I found a solution to this by always cloning the source in this single node case but this has a small perf loss we would need to spend more time testing. I think the mutation of the source node in situations like this is fine as no one should be using idiomorph like this in real world use case and anyone using it this way in old deployments would have had issues anyway before. I also think that the test fidelity tests are not designed well to handle the way idiomorph can work to retain things. the fidelity test as it is written right now does not handle the tests you have written and to fix this it would have to insert the initial as a child in the dom and then compare the finial child contents with the expected value and not the initial value that can be moved by moveBeforeId stuff. The current testing just creates an orphaned node and then mutates it to the destination content and this will just never match this test for these edge cases. You can probably just move these tests to use a different manual testing strategy instead of fidelity.js. maybe ops.js but not sure. |
|
Retested your extra tests in my test branch where i removed duck tape solution and it seems to me the duck tape is not the real issue here. just a simple missed case with the query selector so I think your fix is fine. And those last two tests are just invalid so i would ignore them and do it more the way you have in your first .only test. |
|
@MichaelWest22 Thank you for your keen perspective, as always! I agree with your assessment, and I'll clean this up accordingly. |
4d74025 to
b4770d6
Compare
|
@MichaelWest22 Okay, cleaned up and green, so merging. The return values are still off, but that should be fixed by #129 |
Summary
While fixing another bug, I stumbled upon a corner case issue. Consider the following situation:
When all of the above are true, a type error is raised:
TypeError: Cannot read properties of null (reading 'id') at removeElementFromAncestorsIdMapsExample
<hr id="a">=><div><hr id="a"></div>The first commit has this in a failing test.
WIP Analysis
moveBeforeByIdfails to consider the case where thectx.targetis the IDed node to move.