Child tag won't inherit parent's properties if it's mounted in a loop #1897

Closed
5angel opened this Issue Jul 19, 2016 · 4 comments

Projects

None yet

3 participants

@5angel
Contributor
5angel commented Jul 19, 2016

This time I caught a wild one: http://plnkr.co/edit/YCozy6N2pJ4qWgN24RjI?p=preview

What I think is happening is that 'mount' gets called before props are inherited, causing an inconsistent behavior.

  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@5angel
Contributor
5angel commented Jul 19, 2016

Yup, here it is: https://github.com/riot/riot/blob/master/lib/browser/tag/each.js#L131

So it seems you should listen to 'update', not to 'mount', if you want to use inherited props.
This one works fine: http://plnkr.co/edit/4RP2fKUzRYhGhPh5KlcN?p=preview

@Zmaon
Zmaon commented Jul 19, 2016

From what I understand, the issue is simply that parent-tag has not added the entry to its list when mount() is called in child-tag. I don't think that this is a bug...

Here is another plunker illustrating this: http://plnkr.co/edit/L7HOge4F0t9N0K9kcmB8?p=preview

@5angel
Contributor
5angel commented Jul 19, 2016

As I mentioned earlier, properties are inherited when parent tag updates, which happens after you mount the child tag.

I can fix this by moving this out of the update callback to the separate function and calling it both there and here

@GianlucaGuarini
Member

Note that this behavior will be completely removed in riot@3.0.0 #1697

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment