From 22a66cb6e243a3f1c867b62e3942fd2e828019d9 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 8 Mar 2012 13:56:09 -0800 Subject: integrating v0.7 montage into ninja Signed-off-by: Valerio Virgillito --- node_modules/montage/ui/slot.reel/slot.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'node_modules/montage/ui/slot.reel') diff --git a/node_modules/montage/ui/slot.reel/slot.js b/node_modules/montage/ui/slot.reel/slot.js index 818cc68d..41220373 100755 --- a/node_modules/montage/ui/slot.reel/slot.js +++ b/node_modules/montage/ui/slot.reel/slot.js @@ -27,7 +27,8 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u */ delegate: { enumerable: false, - value: null + value: null, + serializable: true }, /** Description TODO @@ -108,11 +109,9 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u if (this.delegate && typeof this.delegate.slotElementForComponent === "function") { nodeToAppend = this.delegate.slotElementForComponent(this, this._contentToAppend, nodeToAppend); } - this._contentToAppend.element = nodeToAppend; - } - - if (!this._contentToAppend.parentComponent) { - this._contentToAppend._cachedParentComponent = this; + this._contentToAppend.setElementWithParentComponent(nodeToAppend, this); + } else { + this._contentToAppend.setElementWithParentComponent(this._contentToAppend.element, this); } // The child component will need to draw; this may trigger a draw for the slot itself @@ -140,7 +139,6 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u if (child.element.parentElement == null) { // by the time a child component lets us know it's about to prepare to draw for the first time // we know we need to append its element to our own element. - // This happens outside of any drawing for better or worse right now. this._element.appendChild(child.element); this.needsDraw = true; } @@ -247,10 +245,7 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u // Introduce to the componentTree if content appended was a component if (this._contentToAppend && (typeof this._contentToAppend.element !== "undefined")) { - this._contentToAppend.attachToParentComponent(); - // HACK: gets around the issue of the component never being part of the draw loop again because of the idempotence of the needsDraw = true. - this._contentToAppend.needsDraw = false; - this._contentToAppend.needsDraw = true; + this.childComponents = [this._contentToAppend]; } } @@ -285,7 +280,7 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u // If the old content was a component, remove it from the component tree if (this._contentToRemove && this._contentToRemove.parentComponent) { // TODO may also need to remove this from my drawlist, possibly elsewhere too - this._contentToRemove._cachedParentComponent = null; + this._contentToRemove.detachFromParentComponent(); } var removedContent = this._contentToRemove; -- cgit v1.2.3