_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

Make "take" command resilient to null values

Open benpate opened this issue 3 years ago • 0 comments

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 :)

benpate avatar May 15 '22 17:05 benpate