Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

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

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

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

add0n opened this issue Mar 30, 2012 · 2 comments
Labels

Comments

@add0n
Copy link
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.

@imalberto
Copy link
Contributor

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.

@caridy
Copy link
Contributor

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 as completed Jan 29, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants