_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

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

Open 8549 opened this issue 1 year ago • 3 comments

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 avatar Aug 06 '24 17:08 8549

I debugged the script execution and found that the culprit is in the implementation of Runtime.forEach() https://github.com/bigskysoftware/_hyperscript/blob/1e65fb101e2953f680ce958f7de31c266356ad87/src/_hyperscript.js#L1530-L1544 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

8549 avatar Aug 23 '24 15:08 8549

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

sanchawebo avatar Aug 28 '24 09:08 sanchawebo

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

8549 avatar Aug 28 '24 09:08 8549

this is fixed now https://github.com/bigskysoftware/_hyperscript/commit/3884fbad117ae98d68733217b00c55f909e2a678

1cg avatar Dec 13 '24 21:12 1cg