Skip to content

fix #198: connected/disconnected events cannot dispatch to nested component #199

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

Merged
merged 5 commits into from
Feb 23, 2018

Conversation

liming
Copy link
Contributor

@liming liming commented Feb 21, 2018

This PR is trying to fix #198

@coveralls
Copy link

coveralls commented Feb 21, 2018

Coverage Status

Coverage remained the same at ?% when pulling 41a4531 on liming:master into 5a42ccf on WebReflection:master.

@liming
Copy link
Contributor Author

liming commented Feb 21, 2018

Added coverage files.

@WebReflection
Copy link
Owner

thanks for the PR but please not so easy ... I don't want events to dispatch twice if a parent with a connected callback has children with connected callbacks and there is no test around this PR.

Can we have a test case that ensure things work as expected and the parent doesn't trigger twice?
Thanks

@liming
Copy link
Contributor Author

liming commented Feb 22, 2018

Hi @WebReflection ,

I don't understand why parent connected callback is triggered multiple times. I wrote the test case the parent connected callback is triggered multiple times (bubbling). But in real project it's only triggered once. Theoretically the CONNECTED & DISCONNECTED events would not bubble by default. Because the new Event has bubbles options default to false.

I added test case to cover the events test. Could you help to have a look why it's not working? Thanks.

@WebReflection
Copy link
Owner

@liming it could be an issue in basicHTML. Look, I might just merge this and figure out how to fix that but I'd like to be aligned on what we think should be the expected behaviour accordingly to this change

  1. the parent connected callback is dispatched before each child node
  2. children should dispatch before parent (as in bubbling order, even if no bubbling)

In top down order, the parent is connected and after its children but as bubbling/setup order one might expect children to fire before the parent ... or not?

I'm a bit puzzled, please help me with this and I'll merge your changes, fix the issue, and push the new version.

Thank You!

@WebReflection
Copy link
Owner

@liming I've counter-verified indeed there was a bug in basicHTML, now fixed (but it's not in here yet, will push changes ASAP)

@WebReflection
Copy link
Owner

@liming done.

If you could put in the package.json the version "basichtml": "^0.13.2", you won't have conflicts with master and the test should pass as expected.

Apologies for the inconvenient.

@liming
Copy link
Contributor Author

liming commented Feb 22, 2018

Hi @WebReflection ,

I updated the package.json and test cases works! Thanks for the fix. It's good to merge and release a new patch :)

@WebReflection
Copy link
Owner

@liming please give me some quick thoughts on this comment and I'll eventually merge and release, thanks.

@liming
Copy link
Contributor Author

liming commented Feb 22, 2018

Hi @WebReflection ,

The onconnect event is reflecting the sequence of DOM creation, in which the parents are created before children. Bubbling is the children letting their parent know something happened about themselves. If parents received an onconnect event bubbled from its child, this onconnect is actually say the child get birth instead of parent itself. The target of this event would be child but not parent.

We are talking about DOM creation order in regards to onconnect event. I think it make sense for parents receive the event before its children.

Does the explain make you less puzzled?

@WebReflection WebReflection merged commit f2c1b48 into WebReflection:master Feb 23, 2018
@WebReflection
Copy link
Owner

published as v2.5.11

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.

connected/disconnected events cannot dispatch to nested components
3 participants