Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[bz5440307] ac.composite.execute() fails with an empty children list #60

Closed
add0n opened this Issue Mar 30, 2012 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

add0n commented Mar 30, 2012

If you pass an empty object for the children property in your cfg to ac.composite.execute(), Mojito will sort of just hang there. I think I've tracked the issue down to lines 260-262 of composite.common.js (in the function AdapterBuffer.done).

What I think happens is that the buffer.counter property will start at 0, and gets decremented to -1:

if(--this.buffer.counter === 0){
this.callback();
}

... so this.callback() will never execute. In my case, I'd greatly prefer it if it checked for counter <= 0 instead of === 0, so that it could handle empty children objects elegantly.

FYI, my current workaround is to include a dummy child that won't get output anywhere.

Contributor

imalberto commented Jun 7, 2012

Is a composite mojit with no "children" considered valid configuration ?
If not, then perhaps do the same check as in ac.composite.done() and throw an error if size is 0.

Collaborator

caridy commented Jan 29, 2013

            if (!children || Y.Object.size(children) === 0) {
                throw new Error('Cannot run composite mojit children because' +
                                ' there are no children defined in the' +
                                ' composite mojit spec.');
            }

In 0.5.x we have that check in place.

@caridy caridy closed this Jan 29, 2013

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