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

Allow non-id selectors in hx-select-oob to fix #2561 #2585

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

cadrgtsecond
Copy link

Description

This pull request fixes #2561. I retargeted it against v1 as suggested on discord. I found this issue with the hx-select-oob attribute while trying to help a beginner on discord. This technically breaks an obscure behavior of adding back # to a selector if it does not begin with a #. This behavior is neither documented nor tested. In fact, the documentation suggests you can use this with any CSS selector, not just id selectors(though it does not give an example).

Each value in the comma separated list of values can specify any valid hx-swap strategy by separating the selector and the swap strategy with a :.

As I have explained in the issue, this can cause really strange behavior when combined with non-id selectors by reinterpreting them as id selectors(and that too not even properly).

Testing

I added tests for non-id selectors and tests for non-id selectors with colons. I also added missing tests for hx-select-oob with different swap styles

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

@Telroshan Telroshan added bug Something isn't working 1.0 labels Jun 2, 2024
@Telroshan Telroshan added the ready for review Issues that are ready to be considered for merging label Jul 22, 2024
src/htmx.js Outdated Show resolved Hide resolved
@cadrgtsecond
Copy link
Author

Sorry I'm a bit late. I was a bit busy

@1cg 1cg merged commit 30ab5c1 into bigskysoftware:v1 Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 bug Something isn't working ready for review Issues that are ready to be considered for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants