Closed RuthgerD closed 7 months ago
For your specific example, I think you can simply have:
return div(() => el.val = a({self: el}, /* some text */),
...
)
That said, it's advised to avoid setting the value of the state to a DOM element, see https://vanjs.org/advanced#why-not-dom-valued-states.
My hopefully legitimate use case is scrolling the container from within a callback that is defined within the body of the container I want to scroll, but your suggestion actually fits nicely I think; I am not too literate in all the javascript tricks! thanks :)
To keep it short, I am looking for a way to do this: https://svelte.dev/docs/element-directives#bind-this
where today you need to create the element, assign it to a variable and then return the variable again.
What I would like to write is something along the lines of:
but today I need to write:
similarly, I find myself sometimes needing to access an element from a callback, and the dance to do this less nice as well.
I hope this can be somehow considered, thanks!