docs for `wait` command include invalid syntax
CharlesTaylor7 opened this issue · comments
Problem
The documentation for the wait
command advertises syntax that doesn't actually parse.
On this page of the docs:
https://hyperscript.org/commands/wait/#description
This snippet:
wait for load or 1s
if the result is not an Event
throw 'Took too long to load.'
end
Workaround
The comparison the result is not an Event
, fails to parse, but replacing the an
with an a
makes it hunky dory.
Potential Fix
Either we can (1) update the docs, or (2) update the parser to allow the construct of is not an Event
.
I personally favor extending the parser to make this work.
Error
![Screen Shot 2024-02-09 at 6 45 14 PM](https://private-user-images.githubusercontent.com/16541866/303799069-134fffdb-a2a6-4027-91cb-4b6fd7cef81f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzNTMwMTAsIm5iZiI6MTcyMjM1MjcxMCwicGF0aCI6Ii8xNjU0MTg2Ni8zMDM3OTkwNjktMTM0ZmZmZGItYTJhNi00MDI3LTkxY2ItNGI2ZmQ3Y2VmODFmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDE1MTgzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI5NzE4MDBkZTFlYmQ3YjFhZjUwM2M5ZGZiOTljMzEzZGE2MDdiNmRjMDM4NjFkMjc4ZTBhM2M2NDcwNGU1YmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.62oJa8g0857Nm5Gzbg-5dPjkRDVOn7K6haU5dszzx60)
Stacktrace:
at a.raiseParseError (http://unpkg.com/hyperscript.org@0.9.12:1:12649)
at i.raiseError (http://unpkg.com/hyperscript.org@0.9.12:1:6620)
at i.requireToken (http://unpkg.com/hyperscript.org@0.9.12:1:7520)
at http://unpkg.com/hyperscript.org@0.9.12:1:71097
Apart from the parser problem mentioned above, I tried implementing a wait with an event or a duration like in the example (the only difference is that I'm doing it from a function in a ".hs" file and not directly on the HTML element), but the script results in a deadlock, waiting forever for the event to occur. The duration is never considered. If I use the duration alone, there is no problem. Is anyone else having the same issue?
EDIT: To add a nuance to what I'm saying, the code above is working except if we start to use the trigger and the from clause of the wait command like this:
<button _="on click put 'Started...' into the next <output/>
set continuer to the next <button/>
wait for a continue from continuer or 3s -- wait for a continue event...
if the result's type is 'continue'
put 'Finished...' into the next <output/>
otherwise
put 'Timed Out...' into the next <output/>
end
wait 2s
put '--' into the next <output/>">
Start
</button>
<button _="on click trigger continue">
Continue
</button>
<output>--</output>
Maybe I misunderstood the way it works. If someone can help on this I will be very grateful. Thanks.