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

toggling @disabled on the next select actually toggles it on its children options #558

Open
8549 opened this issue Aug 6, 2024 · 3 comments

Comments

@8549
Copy link

8549 commented Aug 6, 2024

Code to reproduce (tested in playground):

<form action="/add" method="post" autocomplete="off">
  <input type="checkbox" name="have_p" _="on change toggle @disabled on the next <select/>" />
  <select name="p_format" required>
    <option value="a">A</option>
    <option value="b">B</option>
  </select>
</form>

Issue persists even by addressing the select with an id or by targeting the parentElement of the next <option/>.

@8549 8549 changed the title toggling @disabled on the next <select/> actually toggles it on its children options toggling @disabled on the next select actually toggles it on its children options Aug 8, 2024
@8549
Copy link
Author

8549 commented Aug 23, 2024

I debugged the script execution and found that the culprit is in the implementation of Runtime.forEach()

forEach(value, func) {
if (value == null) {
// do nothing
} else if (this.isIterable(value)) {
for (const nth of value) {
func(nth);
}
} else if (this.isArrayLike(value)) {
for (var i = 0; i < value.length; i++) {
func(value[i]);
}
} else {
func(value);
}
}

the HTMLSelectElement which is passed as value is considered an iterable so the wrong else-if branch is executed (and the toggle command is executed on the select's iterables -- its children options!) instead of the default (call once func on value).
immagine

@sanchawebo
Copy link

I currently have the same problem. Did you happen to find a workaround for this?

@8549
Copy link
Author

8549 commented Aug 28, 2024

@sanchawebo The dev confirmed that he's going to fix this issue in September:
immagine

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