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

on click toggle [@checked] on <input[type='checkbox']:not(checked)/> works in playground but not elsewhere #584

Closed
mkgn opened this issue Oct 23, 2024 · 1 comment

Comments

@mkgn
Copy link

mkgn commented Oct 23, 2024

playground html i tried

<div>
<button _="on click toggle [@checked] on <input[type='checkbox']:not(checked)/>" >check all</button>
<input type="checkbox" class="ctrl"/>
<input type="checkbox" class="ctrl"/>
<input type="checkbox" class="ctrl"/>
</div>

check-all toggles all the checkboxes as expected. However when i do the same in my application it gives me below error

on click toggle between [@checked] on <ul#moduleSelector input[type='checkbox']:not(checked)/>
                        ^^
 Error: Expected 'and' but found '[@checked]'

according to documentation toggle works with classes only. Then, how come the above works in playground? I am using hyperscript 0.9.13. Is playground using a different version?

@1cg
Copy link
Contributor

1cg commented Dec 17, 2024

That's the older, deprecated syntax for toggling attributes, it should still work (we have a test here:

var div = make("<div _='on click toggle [@foo=\"bar\"]'></div>");
)

The new syntax is:

on click toggle @checked on <input[type='checkbox']:not(checked)/>

However this can be a little confusing since this toggles the attribute rather than the checked value, which behaves differently

@1cg 1cg closed this as completed Dec 17, 2024
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