Thomas 'PointedEars' Lahn wrote:
> Martin Honnen wrote:
>> If I simply use
>>
>> <input type="button" value="test"
>> onclick="var response = await fetch(location.href);">
>>
>> I get an error "Unexpected identifier".
Me too. To be precise, a SyntaxError exception with that message is thrown
and not caught.
>> Is there any way to designate an event handler content attribute as an
>> async function body?
>
> I do not know of any. The obvious solution might be
>
> onclick="(async function () {
> var response = await fetch(location.href);
> }())"
>
> or
>
> onclick="async function blub () {
> var response = await fetch(location.href);
> }; blub();"
Both work in
| Chromium 57.0.2987.98 (Developer Build) Built on 8.7, running on Debian stretch/sid (64-bit)
| Revision a6a06b78087c9fdb4b12fe0ac1b87fdc10179f8b
| OS Linux
| JavaScript V8 5.7.492.63
| […]
| User Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36
| Command Line /usr/lib/chromium/chromium --disk-cache-size=44040192 --show-component-extension-options --ppapi-flash-path=/usr/lib/pepperflashplugin
nonfree/libpepflashplayer.so --ppapi-flash-version=23.0.0.207 --flag-switches-begin --ignore-gpu-blacklist --flag-switches-end
(<chrome://version>)
So if I had to use one of them, I would use the first one (the AFE).
However, why would one want to produce spaghetti code?