Closed halfnelson closed 5 years ago
It works when using on:click={change}
(note the colon :
)
Thank you. Although if I recall on:click does an addEventListener('click',...)
. Not sure that helps if the element is a WebComponent that wants a callback and does expose a custom event. eg
<stockticker-web-component onConnectionError="{errorHandler}"/>
I'm going through and trying to clean up old issues, and I think this one falls under 'that's just how web components work'. Afaik you can only pass strings to web components via attributes when you're using them in regular HTML, and I don't see a different non-confusing way we could handle this.
https://v3.svelte.technology/repl?version=3.0.0-alpha27&gist=9351806a082bdb1d1564e78eb423f27c
setting
onclick={somefunction}
results in the dom containingonclick="function somefunction() ..."
.Setting via spread props works. This is because the first method generates
setAttribute
call and the second generates asetAttributes
call. ThesetAttributes
call has a codepath that will set the value on the element using its property if it can whereas setAttribute always uses the dom's node.setAttribute() call.Should these be consistent? is this expected?