Skip to content

Fix upsert so it processes the matched node#3727

Open
MichaelWest22 wants to merge 1 commit intobigskysoftware:four-devfrom
MichaelWest22:upsert-process-fix
Open

Fix upsert so it processes the matched node#3727
MichaelWest22 wants to merge 1 commit intobigskysoftware:four-devfrom
MichaelWest22:upsert-process-fix

Conversation

@MichaelWest22
Copy link
Copy Markdown
Collaborator

Description

when upsert matches on an id'ed node it uses outerHTML replacement which creates a new node and this prevents the updated node getting processed by htmx which prevents any nodes from hosting active htmx controls. only newContent children nodes are processed after the custom swap happens unless you explicitly return an array of nodes to process and upsert just returns true and so the original unused child node is processed but not the newly created one via outerHTML assignment.

To fix this we just need to use replaceWith instead which then uses the newContent node correctly.

Corresponding issue:
#3725

Testing

Added test to reproduce the issue

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 Apr 4, 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