handle processing morph placeholder nodes#3884
Open
MichaelWest22 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
There is an edge case where the newContent processing of outerMorph does not catch one situation well. We currently do not fully resolve all outerMorph inserted nodes due to the added complexity required so instead we track the newContent nodes plus the target node and process these as Nodes are either inserted new or the target node is morphed in place. But if you break the morph by changing root tags and you still have persistent id children contained in the now completely different parent node (this is a wierd edge case that would never happen in practice but is possible if you replace the nodes completely and include a hx-preserve node you want to move to the new different structure). When the moprh detects that there are persistent id's that need retaining in a node even though the node is not morphable it creates a new placeholder node and morphs the new node in as just placing the new node in instead can cause problems for the id nodes inside moving levels etc. But this placeholder node is now not the same node as the newContent nodes we started with and it could replace the main target node and in this rare edge case this placeholder node is never processed.
To patch this edge case i've just added an extra process command that just processes this placeholder node after it is inserted to ensure it will always be processed correctly.
Also found some dead code in morphing isSoftMatch that is meant to only be in the alpine compat extension and got left in core by mistake so removing this as well.
Corresponding issue:
#3882
Testing
Added test for this edge case
Checklist
masterfor website changes,devforsource changes)
approved via an issue
npm run test) and verified that it succeeded