There seem to be some issues in accessing nested widgets when there are gaps between widgets. In this case we have some parentWidget. And then we create children widgets (similar issues can be replicated when using custom tags rather than invoked renderer).
Say that we have some child templates (foo, bar, and baz). Only baz is an actual marko widget, while foo and bar are just template.marko files.
data.renderers = [
require('./foo'),
require('./bar'),
require('./baz')
];
Then we assign nested widgets as follows (although these are not all "true" widgets):
<for each="renderer in data.renderers">
<invoke function="renderer(myInputObject, out)" w-id="childWidget[]" />
</for>
This will result in markup as follows:
<div class="foo">foo</div>
<div class="bar">bar</div>
<div class="baz" id="parentWidget[0]-childWidget[2]">baz</div>
The childWidget in this case starts at index 2, because foo and bar were correctly skipped. However, when trying to access the nested widgets, this gap seems to cause problems.
parentWidget.getWidgets('childWidget') // comes up empty
Should everything be created as widget to begin with, in order to avoid issues like this? Wouldn't that create unnecessary overhead? Ideally we would only use w-id when we know it's a widget we want to access, but I imagine in some cases that may not be possible when using both widgets and non-widgets similarly.