File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -694,6 +694,26 @@ Comparisons can be combined via the `and`, `or` and `not` expressions in the usu
694694 add .highlight to the closest <form/>
695695 ~~~
696696
697+ Note that ` and ` and ` or ` will short circuit in the normal manner:
698+
699+ ~~~ hyperscript
700+ if false and foo() # foo() will not execute
701+ ~~~
702+
703+ with one important caveat: if the first expression returns a Promise rather than a synchronous value, it will be interpreted
704+ as truthy:
705+
706+ ~~~ hyperscript
707+ if returnsPromise() and foo() # foo() will execute, even if the promise resolves to false
708+ ~~~
709+
710+ To work around this, you can move the promise-based value out to a separate statement:
711+
712+ ~~~ hyperscript
713+ get returnsPromise()
714+ if the result and foo() # foo() will not execute if promise resolves to false
715+ ~~~
716+
697717#### Loops {#loops}
698718
699719The [ repeat command] ( /commands/repeat ) is the looping mechanism in hyperscript.
You can’t perform that action at this time.
0 commit comments