dom-expressions
dom-expressions copied to clipboard
Is it possible to bind event to rootElement ?
Background
https://github.com/solidjs/solid/issues/1786
event. stopPropagation
is not work as expected.
Solution
Change the render
and delegateEvents
in dom-expressions/src/client.js
let ROOT_ELEMENT = window.document
export function render(code, element, init, options = {}) {
ROOT_ELEMENT = element
}
export function delegateEvents(eventNames, document = ROOT_ELEMENT) {
}
That would be a very specific and arbitrary solution for the render
function, and not flexible across multiple render() calls.
The concept of delegation should be totally decoupled from exactly which element we render to. We might like delegation to be on any arbitrary node besides the one we render to.
I also mentioned in
- https://github.com/solidjs/solid/issues/1786
that not delegating by default would be great.
Event delegation is important for portals and pre-emptive hydration techniques. I think it might be possible for Portals to have a different delegation approach(I believe React did something like this for React 17) but this is definitely something that is involved. Especially considering multiple/render hydration entries in things like Islands.