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

oncreate order should reflect component order #1135

Closed
Rich-Harris opened this issue Jan 26, 2018 · 1 comment · Fixed by #1137
Closed

oncreate order should reflect component order #1135

Rich-Harris opened this issue Jan 26, 2018 · 1 comment · Fixed by #1137
Labels

Comments

@Rich-Harris
Copy link
Member

No REPL, pending sveltejs/v2.svelte.dev#205, but if you have a situation like this...

<!-- App.html -->
<Nested name='foo'/>
<Nested name='bar'/>

<script>
  import Nested from './Nested.html';

  export default {
    components: {
      Nested
    }
  };
</script>
<!-- Nested.html -->
<p>{{name}}</p>

<script>
  export default {
    oncreate() {
      console.log(`oncreate ${this.get('name')}`);
    }
  };
</script>

...you would reasonably expect the console to show

oncreate foo
oncreate bar

but the order is reversed. This breaks expectations and makes it harder to, for example, wait for some data for foo to load before attempting to load data for bar (which is exactly what I'm currently experiencing).

I think this qualifies as a bug, so reversing the order needn't be considered a breaking change.

@Conduitry
Copy link
Member

I imagine this should be an .unshift - or else this should be a .shift. Not sure how or whether we should be worrying about _beforecreate or _aftercreate.

Rich-Harris added a commit that referenced this issue Jan 26, 2018
Rich-Harris added a commit that referenced this issue Jan 26, 2018
Fix order of `oncreate` in sibling components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants