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

Incomplete support for "data-" prefix #19

Closed
jsampson opened this issue May 18, 2020 · 3 comments
Closed

Incomplete support for "data-" prefix #19

jsampson opened this issue May 18, 2020 · 3 comments

Comments

@jsampson
Copy link
Contributor

jsampson commented May 18, 2020

While the docs say that the "data-" prefix is supported for all "hx-" attributes, there appear to be several places in the code that do not honor it. This is based on reviewing the code, not running it. The unit tests don't have coverage for "data-" prefixes, and I haven't reproduced any of these issues.

  • L27: comment mentions "kt and data-kt prefixes"
    • should become "hx and data-hx prefixes"
  • L53: getClosestAttributeValue uses getRawAttribute
    • should use getAttributeValue
  • L293 & L295: getTarget uses getRawAttribute for "hx-target"
    • should use getAttributeValue
  • L631: initScrollHandler uses querySelectorAll("[hx-trigger='revealed']")
    • could be querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']")
  • L801: getHistoryElement uses querySelector('[hx-history-elt]')
    • could be querySelector("[hx-history-elt],[data-hx-history-elt]")
  • L858: loadHistoryFromServer uses querySelector('[hx-history-elt]')
    • could be querySelector("[hx-history-elt],[data-hx-history-elt]")
  • L1095: issueAjaxRequest uses getRawAttribute for "hx-target"
    • should use getAttributeValue
@1cg
Copy link
Contributor

1cg commented May 18, 2020

Good catches.

Should probably have a test in each attribute test for the "data-" prefix.

@jsampson
Copy link
Contributor Author

Yep, that probably makes sense. I've added notes in the issue description about the likely fixes. After a bit of experimenting in the browser console It seems like the comma in selectors works as "or" just like in CSS. There might be something more elegant.

I added an Htmx binding in Remarker (my server-side rendering library that nobody uses) and decided to use the "data-" prefixed attributes on a lark. Then figured I should check how/whether they work. :)

1cg pushed a commit that referenced this issue May 23, 2020
clean up uses of getRawAttribute() and add a `data-*` test for all attribute tests.
@1cg
Copy link
Contributor

1cg commented May 23, 2020

fixed by ba6d38e

@1cg 1cg closed this as completed May 23, 2020
strangeRabbit777 added a commit to strangeRabbit777/high-power-tool that referenced this issue Aug 23, 2022
clean up uses of getRawAttribute() and add a `data-*` test for all attribute tests.
strangeRabbit777 added a commit to strangeRabbit777/high-power-tool that referenced this issue Aug 25, 2022
clean up uses of getRawAttribute() and add a `data-*` test for all attribute tests.
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

2 participants