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

upgrading from Hogan templates to HTML tagged templates does not allow for custom attributes #5435

Closed
1 task done
srconklin opened this issue Jan 17, 2023 · 3 comments
Closed
1 task done
Labels

Comments

@srconklin
Copy link

🐛 Current behavior

using Hogan.js custom attributes were possible. For example, adding custom click handler syntax to an anchor tag from 3rd party libraries like alpine.js https://alpinejs.dev/directives/on


 instantsearch.widgets.hits({
     item (hit) { 

         return ' <a href="#" @click.prevent="$dispatch('show-modal', { itemno: '${hit.itemno}' })">'
...

Now when upgrading to HTML templates due to Hogan deprecation (https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates), the following error is thrown:

image

🔍 Steps to reproduce

follow the upgrade guide to replace them either with safe HTML strings using the provided html tagged template, or JSX templates as described above

Live reproduction

sandbox.dynaprice.com

💭 Expected behavior

allow for custom attributes on dom elements.

Package version

"instantsearch.js": "^4.49.1"

Operating system

Windows 10

Browser

Chrome v. 109.0.5414.74

Code of Conduct

  • I agree to follow this project's Code of Conduct
@srconklin srconklin added the triage Issues to be categorized by the team label Jan 17, 2023
@Haroenv Haroenv added Library: InstantSearch.js Issues in instantsearch.js Scope: Templating and removed triage Issues to be categorized by the team labels Jan 17, 2023
@Haroenv
Copy link
Contributor

Haroenv commented Jan 17, 2023

For now, a workaround would be using the spec-compliant x-on instead of @. I believe this is because we previously used innerHTML, while now setAttribute is used (and @something isn't a valid attribute)

@srconklin
Copy link
Author

For now, a workaround would be using the spec-compliant x-on instead of @. I believe this is because we previously used innerHTML, while now setAttribute is used (and @something isn't a valid attribute)

thanks, will try that

@Haroenv
Copy link
Contributor

Haroenv commented Apr 11, 2023

We won't be able to find a solution for this unfortunately, as setAttribute is throwing. x-on or onClick=${myFunction} should be used instead.

@Haroenv Haroenv closed this as completed Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants