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

multi-swap default swapStyle #80

Closed
goamaral opened this issue Aug 15, 2024 · 2 comments
Closed

multi-swap default swapStyle #80

goamaral opened this issue Aug 15, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@goamaral
Copy link

I have set htmx.config.defaultSwapStyle = "outerHTML".
I expected multi-swap to use this as well but it defaults to "innerHTML".
var elementSwapStyle = typeof (split[1]) !== 'undefined' ? split[1] : 'innerHTML'
Any reason for this behaviour?

Also, any reason the hx-swap is not sent as a header?

Thank you for taking the time

@Telroshan
Copy link
Collaborator

Hey, as stated in the multi-swap doc

Default swap method is innerHTML.

As for,

Any reason for this behaviour?

Can't really tell as I wasn't there when it was written, one thing I can say is that if we were to change that default, it would be a breaking change, so for backwards compatibility concerns, we can't change it.
Though, note you could totally copy the extension locally and change the default value if you need it:

var elementSwapStyle = typeof (split[1]) !== 'undefined' ? split[1] : 'innerHTML'

On another note, I personnally wouldn't recommend using this extension at all, as its premise is simply untrue:

OOB requires HTML tags marked with hx-swap-oob attributes to be at the TOP level of HTML, which significantly limited its use. With OOB, it's impossible to swap multiple elements arbitrarily placed and nested in the DOM tree.

That is actually false, and has been for 3 years.
I had removed that mention in the lib's doc last year but I totally forgot it was also mentioned here.

So for a very personal opinion, I'd suggest simply using oob swap instead and no extension at all for this matter.

Also, any reason the hx-swap is not sent as a header?

What would be the use of such header? Note that we don't send everything as headers, and new headers have been implemented over time as the community needed it, or suggested a usecase that felt relevant to us. So feel free to defend your opinion here, we can always be convinced. But we'll need more information about its usage!

@Telroshan Telroshan added the documentation Improvements or additions to documentation label Aug 16, 2024
@goamaral
Copy link
Author

Hey, everything you stated sounds reasonable.
Thanks for taking the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants