_hyperscript
_hyperscript copied to clipboard
Issues with 'remove' command example and causes internal error
In the documentation of the remove
command (https://hyperscript.org/commands/remove/), there is an example:
<button _="on click remove [disabled]">Un-Disable Me!</button>
I belive there is multiple errors in this example and does not work, because:
A. Correct expression for attribute is @disabled
, not [disabled]
B. Disabled button does not fire on click
C. Button is not disabled in first place!
Another issue arises when using from
along with this incorrect square bracket attribute expression (e.g., on click remove [disabled] from #box
). It fails to execute with the error that is probably should not happen: Cannot read properties of undefined (reading 'parentElement')
I'm a bit of a noob at hyperscript, so I apologize if I've missed something.
I agree, it sent me into a rabbit hole, where I tried to remove an attribute by using the [attribute-name]
syntax, while the actual syntax is @attribute-name
as specified under "Attributes" in the documentation.
We should update this file https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/remove.md to reflect the correct syntax for accessing attributes.
Additionally, the point is valid that a disabled button does not trigger events and removing a disabled attribute from a non-disabled button is not very useful.