Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Update to not use _mountImage #2

Merged
merged 1 commit into from
Jan 17, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/ReactART.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ var ContainerMixin = merge(ReactMultiChild.Mixin, {
* Creates a child component.
*
* @param {ReactComponent} child Component to create.
* @param {object} childNode ART node to insert.
* @protected
*/
createChild: function(child) {
var childNode = child._mountImage;
createChild: function(child, childNode) {
child._mountImage = childNode;
var mostRecentlyPlacedChild = this._mostRecentlyPlacedChild;
if (mostRecentlyPlacedChild == null) {
// I'm supposed to be first.
Expand Down Expand Up @@ -140,6 +141,7 @@ var ContainerMixin = merge(ReactMultiChild.Mixin, {
*/
removeChild: function(child) {
child._mountImage.eject();
child._mountImage = null;
},

/**
Expand All @@ -162,8 +164,15 @@ var ContainerMixin = merge(ReactMultiChild.Mixin, {
children,
transaction
);
for (var i = 0; i < mountedImages.length; i++) {
mountedImages[i].inject(this.node);
// Each mount image corresponds to one of the flattened children
var i = 0;
for (var key in this._renderedChildren) {
if (this._renderedChildren.hasOwnProperty(key)) {
var child = this._renderedChildren[key];
child._mountImage = mountedImages[i];
mountedImages[i].inject(this.node);
i++;
}
}
}

Expand Down