_hyperscript
_hyperscript copied to clipboard
Make "take" command resilient to null values
I'd like to be able to do this: take .selected for {non-existent-item} without throwing and error. It seems like, if the from expression resolves to null, then take should just be a NOOP.
Here's a more realistic example that I'm working with in real code:
`take .selected for the previous<[role="menu item"]/> from selected`
If the 'selected' menu item is already at the top of the list, then "previous" returns null. This means I need a cumbersome null check whenever I do something like this, and hypersrcipt could/should be smarter than this :)