Ownership of createComponents

When creating compontents that they themselves have compontents, those inner components end up being owned by the master control.

I created a simple jsfiddle : http://jsfiddle.net/pmarsh/Vwuxr/6/

In that code I would expect to use this : this.$.innerRows.$.innerContent

And not this.$.innerContent

Is this the way that it's supposed to happen? Am I missing an argument or something along the way?


  • Yes, that's the way it is supposed to happen :)
  • Agreed. You're confusing ownership and containment. The $ hash contains kind instances that are owned by "this." By default, instances created by calling obj.createComponent() will be owned by obj. This includes any instance declared in the passed object regardless of the depth of containment.

    So, as you discovered, both innerRows and innerContent are owned by App1 because both were defined in the call to App1.createComponent. If you want innerContent owned by innerRows (and therefore hidden from consumers), you need to either define a new kind with that internal component (like this) or add a second createComponent call (like this). The former is the "enyo" way to do it.
  • Thank you for the explanation makes total sense. We are moving towards the "enyo" way of doing things as we refactor.
Sign In or Register to comment.