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 run order of didInsertParent for children of already-set-up parents #11

Conversation

reidab
Copy link

@reidab reidab commented Apr 18, 2017

Fixes #10

let parentSpy = this.parentSpy = this.spy();
let childSpy = this.childSpy = this.spy();
let childParentSpy = this.childParentSpy = this.spy();
test('top-level parent with children-parents after if', function(assert) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change existing tests rather than adding a new one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually started out with it in a separate test. I moved it here because it wasn't testing a new thing, just clarifying of how the run order should work for parents that were already set up.

I'm happy to split it back out again if you prefer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miguelcobain Ping. Would you like me to split this out into a separate test?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed response, @reidab. Yes please, that would help a lot for me to understand what is going on here!

@@ -55,11 +55,18 @@ export default Mixin.create({
}
},

notifyParentOfInsert: on('didInsertElement', function() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use didInsertParent instead of on('didInsertParent',. It makes the calling order more predictable and provides a better opportunity for subclasses to override the method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with on('didInsertElement'… explicitly to avoid subclasses being able to override this and break the chain. I'll swap it.

@reidab
Copy link
Author

reidab commented Nov 6, 2017

I'd completely forgotten about this PR until I went to update another library I had that depended on it. Apologies!

I've updated the PR to split out the new tests into their own test case and reverted back the changes to existing tests.

@reidab
Copy link
Author

reidab commented Jan 28, 2018

Ping. I've been delaying a library depending on this fix for many months now. Is there anything else I can do to move it forward?

@reidab reidab force-pushed the didInsertParent-for-already-setup-parents branch from 24d3383 to 0b8e1b0 Compare January 29, 2018 20:56
@reidab
Copy link
Author

reidab commented Jan 29, 2018

Just rebased the branch on the current master resolved conflicts.

@Duder-onomy Duder-onomy mentioned this pull request Feb 14, 2018
@Duder-onomy
Copy link
Contributor

Duder-onomy commented Feb 14, 2018

@miguelcobain I just made PR #19 that will fix the Travis failures seen in this PR.

@reidab
Copy link
Author

reidab commented Mar 2, 2018

The description in @Duder-onomy's PR #19 said that it fixed this, so this got auto-closed, but it hasn't actually been merged. 😢

@Duder-onomy
Copy link
Contributor

@miguelcobain This is still an issue, My PR accidentally closed this.. All my PR did was fix TravisCi.
Can you re-open this? Or even better, merge it?

@Duder-onomy
Copy link
Contributor

@miguelcobain Can this be merged?

reidab and others added 5 commits June 4, 2019 13:02
Sharing a single test spy between the two child-components can confuse order-dependent tests
referring to the order of events on a single component. Since the second child-component isn't
necessary for these tests, I'm removing it rather than giving each child-component its own spy.
@Duder-onomy Duder-onomy force-pushed the didInsertParent-for-already-setup-parents branch from 0b8e1b0 to c0bb308 Compare June 5, 2019 19:39
@Duder-onomy
Copy link
Contributor

@miguelcobain This is still an issue, i'm going to try and explain the issue the best I can.

When the change was made to register children on init() instead of didInsertElement(), children of an already-setup parent ( the children were hidden behind some conditional ) are receiving didInsertParent on init, which breaks and code in the didInsertParent hook that relies on the element being available.

@Duder-onomy
Copy link
Contributor

I believe this is the same issue seen in #16 and pull requested in #17.

@knownasilya
Copy link

Ping, just for visibility.

@miguelcobain
Copy link
Owner

The new architecture of ember-composability-tools is a lot different.
I added a modified version of this test to the current test suite and it passed. I can't keep the test though, because it required some hacking of the Node component to make the test possible (Good ol' times when we could just willRender=this.spy and it would end up replacing the component's willRender 😅 ).

In any case, I believe this is fixed, according to my tests. Feel free to reopen if this issue is found.

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.

When a parent is already set up, didInsertParent fires before didInsertElement
4 participants