Skip to content

handle processing morph placeholder nodes#3884

Open
MichaelWest22 wants to merge 1 commit into
bigskysoftware:four-devfrom
MichaelWest22:morph-process-fix
Open

handle processing morph placeholder nodes#3884
MichaelWest22 wants to merge 1 commit into
bigskysoftware:four-devfrom
MichaelWest22:morph-process-fix

Conversation

@MichaelWest22

Copy link
Copy Markdown
Collaborator

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

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@MichaelWest22 MichaelWest22 added the htmx 4 Issues specific to htmx version 4 label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

htmx 4 Issues specific to htmx version 4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant