From 49d5d8feab482e2f516acc410a736c2aa4825aa0 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Mon, 17 Jun 2013 17:17:31 -0700 Subject: [PATCH] track attached RootComponents --- packages/ui/component.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/ui/component.js b/packages/ui/component.js index da21f182da..00542d53ef 100644 --- a/packages/ui/component.js +++ b/packages/ui/component.js @@ -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 = {}; \ No newline at end of file