I am experimenting with Svelte and following the official tutorial. At https://svelte.dev/tutorial/reactive-assignments, I am instructed to use this line of code:
<button on:click={handleClick}>
What is the purpose of the colon? Why isn't it simply <button onclick=...
?
I found the Svelte API documentation on element directives, which provides usage examples within Svelte, but I still don't understand how this is valid JS syntax, or how it is transformed to such. I don't understand how the colon works (as separate from understanding its usage).
I can understand that this was a way to implement a single directive for all DOM event attributes, but its actual functioning is not that transparent to me.
@click
, Angular uses(click)
etc. As mentioned below it's not valid, it's run through some compilation. – Fimble