Skip to content

Commit

Permalink
track attached RootComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreensp committed Jun 18, 2013
1 parent de5b3b7 commit 49d5d8f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/ui/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,33 @@ RawHtmlComponent = Component.extend({
}
});

// A RootComponent is the root of its Component tree in terms
// of parent/child relationships. It's the only kind of
// component that can function without actually being added
// to another component first.

// @export RootComponent
RootComponent = Component.extend({
constructed: function () {
// skip the UNADDED phase completely
this.stage = Component.ADDED;

this._uid = Random.id();
},
render: function (buf) {
var bodyClass = this.getArg('bodyClass');
if (bodyClass)
buf.component(bodyClass.create(), {key: 'body'});
},
attached: function () {
RootComponent._attachedInstances[this._uid] = this;
},
detached: function () {
delete RootComponent._attachedInstances[this._uid];
},
destroyed: function () {
delete RootComponent._attachedInstances[this._uid];
}
});

RootComponent._attachedInstances = {};

0 comments on commit 49d5d8f

Please sign in to comment.