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

fix: Transfer event listeners to content DIV [#96643092] #283

Closed

Conversation

alexanderGugel
Copy link
Member

Event listeners for non-bubbeling events are being listened to by adding an
event listener directly to the element corresponding to the renderable. When
setting the content, the listeners need to be transfered to the content DIV.

Fixes #263

Event listeners for non-bubbeling events are being listened to by adding an
event listener directly to the element corresponding to the renderable. When
setting the content, the listeners need to be transfered to the content DIV.

Fixes Famous#263
@michaelobriena
Copy link
Member

@DnMllr

@alexanderGugel
Copy link
Member Author

@DnMllr Can you review this? This is IMO a pretty serious bug.

@jd-carroll
Copy link
Contributor

Can we always guarantee that the content div will be the same size as the
container? (Or at least be the same size on the next frame)

Why is there a second div for content? I know "render" size presents some
challenges, but isn't there a way to accomplish this without nesting div's?
IMO would rather see the nested div go away...

On Monday, June 29, 2015, Alexander Gugel [email protected] wrote:

@DnMllr https://github.com/DnMllr Any update on this? This is IMO a
pretty serious bug.


Reply to this email directly or view it on GitHub
#283 (comment).

@alexanderGugel
Copy link
Member Author

@jd-carroll

Can we always guarantee that the content div will be the same size as the
container? (Or at least be the same size on the next frame)

Yes.

All edge cases should be handled properly.

Why is there a second div for content? I know "render" size presents some
challenges, but isn't there a way to accomplish this without nesting div's?
IMO would rather see the nested div go away...

We need a second DIV to preserve the ability to have a nested DOM while not pushing down subsequent children if a non-leaf node has content. Render size is handled properly.

@jd-carroll
Copy link
Contributor

@alexanderGugel based on our conversation in #378, would it be necessary to transfer the listeners? Wouldn't it be possible to just maintain the listeners on multiple DOM elements?

As I'm typing this though, I think that would mean there would have to be some sort of stopImmediatePropagation and/or preventDefault logic somewhere. If so, I can see that both positively and negatively.

@michaelobriena
Copy link
Member

@alexanderGugel I think this only solves part of the issue. If you are deeper than the content and you don't bubble we still fail. Curious to think if we should add this even though it doesn't really address the core issue.

@alexanderGugel
Copy link
Member Author

@michaelobriena You are absolutely right. Unfortunately I don't see a way to address this issue without managing the DOMElement's content via some sort of virtual DOM representation (instead of innerHTML). The core issue IMO is that events are added on a per node basis.

@michaelobriena
Copy link
Member

I think we can't do just this approach because it breaks our bubbling model. If you put it on the content DIV, then a child in the scene graph won't have the events bubbled up to the parent. This is a pretty big issue and reason enough to not make this change. I think, as we have talked about internally, we need a real templating system instead of strings.

Closing for now.

@alexanderGugel
Copy link
Member Author

@michaelobriena

If you put it on the content DIV, then a child in the scene graph won't have the events bubbled up to the parent.

No. Because we only add the event listeners to the content DIV for events that don't bubble in the first place. Not adding them to the content DIV means they aren't available at all.

This PR fixes this issue.

@michaelobriena
Copy link
Member

I know, but we break bubbling events like click if do this. So to solve the non bubbling case and bubbling, we need a bigger solution.

@alexanderGugel
Copy link
Member Author

@michaelobriena Can you elaborate on that? click bubbles, therefore it shouldn't be affected at all by this change. E.g. https://github.com/Famous/engine/pull/283/files#diff-18e5f08a4c73b48f46cdd6ef9ff4fd63R177 is not being executed here, since the listener is not being added in the first place.

@michaelobriena michaelobriena reopened this Jul 9, 2015
@michaelobriena
Copy link
Member

Clicking on a child will not trigger a click on the parent if the parent element's listeners are on the content div.

@alexanderGugel
Copy link
Member Author

@michaelobriena It won't trigger the event in either case, since we never add the listener to anything inside the content div.

@michaelobriena
Copy link
Member

Closing since this doesn't address the core issue and would have to be refactored out when a full solution was implemented

@alexanderGugel
Copy link
Member Author

@michaelobriena If you mean the fact that inner events can't be captured, that issue should have been addressed by da0f28d.

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

Successfully merging this pull request may close these issues.

3 participants