Skip to content

Create the swap pantry only when an element moves into it - #4233

Draft
oliverhaas wants to merge 1 commit into
bigskysoftware:four-devfrom
oliverhaas:perf/lazy-swap-pantry
Draft

oliverhaas wants to merge 1 commit into
bigskysoftware:four-devfrom
oliverhaas:perf/lazy-swap-pantry

Conversation

@oliverhaas

@oliverhaas oliverhaas commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

htmx 4 inserted the pantry after <body> on every swap, and a second one on every morph, even when nothing moved into it. In Chrome that can restyle the whole page. Like htmx 2, create it only when an element moves into it.

Corresponding issue: #4232

Testing

See repro in #4232. I also added tests: an hx-preserve swap and a morph that move nothing don't add a pantry anymore (both fail on four-dev), and a preserving swap removes its pantry again.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes) [Assumed four-dev is fine]
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue [No. I hope this is fine just to illustrate what I mean. Feel free to close or replace.]
  • I ran the test suite locally (npm run test) and verified that it succeeded

htmx 4 inserted the pantry after <body> on every swap, and a second one on
every morph, even when nothing moved into it. In Chrome that can restyle the
whole page. Like htmx 2, create it only when an element moves into it.

Refs bigskysoftware#4232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant