aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/slot.reel/slot.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/ui/slot.reel/slot.js')
-rwxr-xr-xnode_modules/montage/ui/slot.reel/slot.js19
1 files changed, 7 insertions, 12 deletions
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
27 */ 27 */
28 delegate: { 28 delegate: {
29 enumerable: false, 29 enumerable: false,
30 value: null 30 value: null,
31 serializable: true
31 }, 32 },
32/** 33/**
33 Description TODO 34 Description TODO
@@ -108,11 +109,9 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u
108 if (this.delegate && typeof this.delegate.slotElementForComponent === "function") { 109 if (this.delegate && typeof this.delegate.slotElementForComponent === "function") {
109 nodeToAppend = this.delegate.slotElementForComponent(this, this._contentToAppend, nodeToAppend); 110 nodeToAppend = this.delegate.slotElementForComponent(this, this._contentToAppend, nodeToAppend);
110 } 111 }
111 this._contentToAppend.element = nodeToAppend; 112 this._contentToAppend.setElementWithParentComponent(nodeToAppend, this);
112 } 113 } else {
113 114 this._contentToAppend.setElementWithParentComponent(this._contentToAppend.element, this);
114 if (!this._contentToAppend.parentComponent) {
115 this._contentToAppend._cachedParentComponent = this;
116 } 115 }
117 116
118 // The child component will need to draw; this may trigger a draw for the slot itself 117 // 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
140 if (child.element.parentElement == null) { 139 if (child.element.parentElement == null) {
141 // by the time a child component lets us know it's about to prepare to draw for the first time 140 // by the time a child component lets us know it's about to prepare to draw for the first time
142 // we know we need to append its element to our own element. 141 // we know we need to append its element to our own element.
143 // This happens outside of any drawing for better or worse right now.
144 this._element.appendChild(child.element); 142 this._element.appendChild(child.element);
145 this.needsDraw = true; 143 this.needsDraw = true;
146 } 144 }
@@ -247,10 +245,7 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u
247 245
248 // Introduce to the componentTree if content appended was a component 246 // Introduce to the componentTree if content appended was a component
249 if (this._contentToAppend && (typeof this._contentToAppend.element !== "undefined")) { 247 if (this._contentToAppend && (typeof this._contentToAppend.element !== "undefined")) {
250 this._contentToAppend.attachToParentComponent(); 248 this.childComponents = [this._contentToAppend];
251 // HACK: gets around the issue of the component never being part of the draw loop again because of the idempotence of the needsDraw = true.
252 this._contentToAppend.needsDraw = false;
253 this._contentToAppend.needsDraw = true;
254 } 249 }
255 } 250 }
256 251
@@ -285,7 +280,7 @@ var Slot = exports.Slot = Montage.create(Component, /** @lends module:"montage/u
285 // If the old content was a component, remove it from the component tree 280 // If the old content was a component, remove it from the component tree
286 if (this._contentToRemove && this._contentToRemove.parentComponent) { 281 if (this._contentToRemove && this._contentToRemove.parentComponent) {
287 // TODO may also need to remove this from my drawlist, possibly elsewhere too 282 // TODO may also need to remove this from my drawlist, possibly elsewhere too
288 this._contentToRemove._cachedParentComponent = null; 283 this._contentToRemove.detachFromParentComponent();
289 } 284 }
290 285
291 var removedContent = this._contentToRemove; 286 var removedContent = this._contentToRemove;