Closed ingiulio closed 9 years ago
On a second thought about the fix, that should probably go even before the view is created, so before this line: https://github.com/rendrjs/rendr/blob/master/shared/base/view.js#L460 I'll just file a PR
Fixed by #463
While playing with our app, I noticed the following into the normal flow of shared/base/view.js:
attachChildViews
is called from the main app view, so when we get toBaseView.attach
, thelist
param will include all the views included in the page, i.e something like:async.map
ofBaseView.attach
, the order in which we get results fromBaseView.getView
matters. Indeed, if for examplechildView1
is returned beforechildViewOfChildView1
, the former will beattach(ed)OrRender(ed)
immediately, which eventually will lead to anotherBaseView.attach
call, where the array of subviews will only be:attachOrRender
is going to be reached and executed both by this current event loop and by the one that started the first BasView.attach, whenBaseView.getView
returns a result forchildViewOfChildView1
.I hope I made this clear enough. If that's not the case, please let me know and I'll try to provide a better explanation. This issue gave me a bit of headache :)
A fix for this would be as easy as just adding this
before this line: https://github.com/rendrjs/rendr/blob/master/shared/base/view.js#L331 Or rather, we could probably mark and filter out subviews from the initial array, but that would definitely take more time and work.
Does this all make sense? Please let me know if I'm just missing something instead.