Skip to content
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

morph:<expr> not usable when using hx-swap-oob with htmx WebSocket extension #40

Open
aral opened this issue Feb 22, 2024 · 1 comment

Comments

@aral
Copy link

aral commented Feb 22, 2024

The issue with hx-swap properties not being available in hx-swap-oob (bigskysoftware/htmx#2308) also affects idiomorph.

Specifically, the following syntax cannot be used:

hx-swap-oob='morph:<expr>'

Use case: I was just trying to make a markdown preview updated via WebSocket scroll into view to show the latest change after the content has been morphed and I can’t.

@aral
Copy link
Author

aral commented Mar 27, 2024

So the fix for this that I implemented in my fork of htmx-2 (which has the hx-swap-oob normalisation PR merged in so it differs from current htmx-2 a bit), was essentially to special-case idiomorph:

(!swapStyle.startsWith('morph:') && swapStyle.indexOf(':') > 0)

at the equivalent of the following line:

https://github.com/bigskysoftware/htmx/blob/bf692737011b40316397d55c3ee756fde6c502cf/src/htmx.js#L1417

This leaves the selector alone and allows it to be parsed properly by idiomorph.

Not making a pull request for this at the moment as it would make more sense to wait for bigskysoftware/htmx#2308 to be resolved and then do so.

You can see the change in my fork of htmx-2 at:
https://codeberg.org/kitten/app/commit/5ee6bf76393445fa8b3fb68295430402b75ae0e1

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

No branches or pull requests

1 participant