Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to bind event to rootElement ? #263

Open
chenzn1 opened this issue Jun 22, 2023 · 2 comments
Open

Is it possible to bind event to rootElement ? #263

chenzn1 opened this issue Jun 22, 2023 · 2 comments

Comments

@chenzn1
Copy link

chenzn1 commented Jun 22, 2023

Background

solidjs/solid#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) {
}

Code location

@chenzn1 chenzn1 changed the title Is it possible to bind eventListener to rootElement ? Is it possible to bind event to rootElement ? Jun 22, 2023
@trusktr
Copy link
Contributor

trusktr commented Aug 26, 2023

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

that not delegating by default would be great.

@ryansolid
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants