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

hyperscript css selector issue #214

Closed
maxwellt opened this issue Apr 26, 2023 · 6 comments
Closed

hyperscript css selector issue #214

maxwellt opened this issue Apr 26, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@maxwellt
Copy link

maxwellt commented Apr 26, 2023

When using Hyperscript in combination with JTE I'm getting a templating error from JTE.

I've setup a demo project to showcase: jte-hyperscript-bug, simply checkout and run ./mvnw spring-boot:run

In the code you'll find one template, index.jte, there you can see the following:

<p _="on load log 'hello world from console'">Hello world</p>

<form action="/login" method="post" _="on submit toggle @disabled on <button[type='submit']/>">
    <input type="email" name="username">
    <input type="password" name="password">

    <button type="submit">Login</button>
</form>

The first hyperscript action (on the p element) works without issues (if you comment out the form). The hyperscript action on the form throws an error, due to the selector being used to target the button. I'm using the CSS selector defined in Hyperscript's documentation.

The error thrown is: gg.jte.TemplateException: Failed to compile index.jte, error at line 20: Unclosed tag <body>, expected </body>, got </form>

If you change it to the following implementation:

<form action="/login" method="post" _="on submit toggle @disabled on #submit-button">
    <input type="email" name="username">
    <input type="password" name="password">

    <button id="submit-button" type="submit">Login</button>
</form>

It does work without issues.

@bohdan-shulha
Copy link

Nice. I was going to post the same.

I have exactly the same problem.

Unfortunately, even with @raw it doesn't work, like this:

<form action="/login" method="post" @raw _="on submit toggle @disabled on <button[type='submit']/>" @endraw>

Anyways, even if @raw would fix this case - I'd need to set some values/selectors based on the data that the controller provides to the view.

@casid casid self-assigned this Apr 26, 2023
@casid casid added the bug Something isn't working label Apr 26, 2023
@casid
Copy link
Owner

casid commented Apr 26, 2023

Thanks for reporting, I have a look at it!

@casid
Copy link
Owner

casid commented Apr 26, 2023

I just published a hotfix version 2.3.2. Probably will take a few hours until it is available on Maven Central. This version should fix this issue.

@bohdan-shulha
Copy link

Wow. It is amazing on how fast did you fix the issue. Thank you. <3

@maxwellt
Copy link
Author

Nice, already available on Maven Central and just tested it out and it works. Thanks for the quick fix!

@casid
Copy link
Owner

casid commented Apr 26, 2023

Thanks for the quick confirmation! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants