Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert ReactMultiChild to plain object #7757

Merged
merged 1 commit into from
Sep 17, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/renderers/art/ReactART.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function injectAfter(parentNode, referenceNode, node) {

// ContainerMixin for components that can hold ART nodes

const ContainerMixin = assign({}, ReactMultiChild.prototype, {
const ContainerMixin = assign({}, ReactMultiChild, {

/**
* Moves a child component to the supplied index.
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ ReactDOMComponent.Mixin = {
Object.assign(
ReactDOMComponent.prototype,
ReactDOMComponent.Mixin,
ReactMultiChild.prototype
ReactMultiChild
);

module.exports = ReactDOMComponent;
2 changes: 1 addition & 1 deletion src/renderers/native/ReactNativeBaseComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ ReactNativeBaseComponent.Mixin = {
*/
Object.assign(
ReactNativeBaseComponent.prototype,
ReactMultiChild.prototype,
ReactMultiChild,
ReactNativeBaseComponent.Mixin,
NativeMethodsMixin
);
Expand Down
54 changes: 27 additions & 27 deletions src/renderers/shared/stack/reconciler/ReactMultiChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ if (__DEV__) {
* children. This is used by `ReactDOMComponent` to mount, update, and
* unmount child components.
*/
class ReactMultiChild {
_reconcilerInstantiateChildren(nestedChildren, transaction, context) {
var ReactMultiChild = {
_reconcilerInstantiateChildren: function(nestedChildren, transaction, context) {
if (__DEV__) {
var selfDebugID = getDebugID(this);
if (this._currentElement) {
Expand All @@ -187,9 +187,9 @@ class ReactMultiChild {
return ReactChildReconciler.instantiateChildren(
nestedChildren, transaction, context
);
}
},

_reconcilerUpdateChildren(
_reconcilerUpdateChildren: function(
prevChildren,
nextNestedChildrenElements,
mountImages,
Expand Down Expand Up @@ -235,7 +235,7 @@ class ReactMultiChild {
selfDebugID
);
return nextChildren;
}
},

/**
* Generates a "mount image" for each of the supplied children. In the case
Expand All @@ -245,7 +245,7 @@ class ReactMultiChild {
* @return {array} An array of mounted representations.
* @internal
*/
mountChildren(nestedChildren, transaction, context) {
mountChildren: function(nestedChildren, transaction, context) {
var children = this._reconcilerInstantiateChildren(
nestedChildren, transaction, context
);
Expand Down Expand Up @@ -278,15 +278,15 @@ class ReactMultiChild {
}

return mountImages;
}
},

/**
* Replaces any rendered children with a text content string.
*
* @param {string} nextContent String of content.
* @internal
*/
updateTextContent(nextContent) {
updateTextContent: function(nextContent) {
var prevChildren = this._renderedChildren;
// Remove any rendered children.
ReactChildReconciler.unmountChildren(prevChildren, false);
Expand All @@ -298,15 +298,15 @@ class ReactMultiChild {
// Set new text content.
var updates = [makeTextContent(nextContent)];
processQueue(this, updates);
}
},

/**
* Replaces any rendered children with a markup string.
*
* @param {string} nextMarkup String of markup.
* @internal
*/
updateMarkup(nextMarkup) {
updateMarkup: function(nextMarkup) {
var prevChildren = this._renderedChildren;
// Remove any rendered children.
ReactChildReconciler.unmountChildren(prevChildren, false);
Expand All @@ -317,7 +317,7 @@ class ReactMultiChild {
}
var updates = [makeSetMarkup(nextMarkup)];
processQueue(this, updates);
}
},

/**
* Updates the rendered children with new children.
Expand All @@ -326,18 +326,18 @@ class ReactMultiChild {
* @param {ReactReconcileTransaction} transaction
* @internal
*/
updateChildren(nextNestedChildrenElements, transaction, context) {
updateChildren: function(nextNestedChildrenElements, transaction, context) {
// Hook used by React ART
this._updateChildren(nextNestedChildrenElements, transaction, context);
}
},

/**
* @param {?object} nextNestedChildrenElements Nested child element maps.
* @param {ReactReconcileTransaction} transaction
* @final
* @protected
*/
_updateChildren(nextNestedChildrenElements, transaction, context) {
_updateChildren: function(nextNestedChildrenElements, transaction, context) {
var prevChildren = this._renderedChildren;
var removedNodes = {};
var mountImages = [];
Expand Down Expand Up @@ -414,7 +414,7 @@ class ReactMultiChild {
if (__DEV__) {
setChildrenForInstrumentation.call(this, nextChildren);
}
}
},

/**
* Unmounts all rendered children. This should be used to clean up children
Expand All @@ -423,11 +423,11 @@ class ReactMultiChild {
*
* @internal
*/
unmountChildren(safely) {
unmountChildren: function(safely) {
var renderedChildren = this._renderedChildren;
ReactChildReconciler.unmountChildren(renderedChildren, safely);
this._renderedChildren = null;
}
},

/**
* Moves a child component to the supplied index.
Expand All @@ -437,14 +437,14 @@ class ReactMultiChild {
* @param {number} lastIndex Last index visited of the siblings of `child`.
* @protected
*/
moveChild(child, afterNode, toIndex, lastIndex) {
moveChild: function(child, afterNode, toIndex, lastIndex) {
// If the index of `child` is less than `lastIndex`, then it needs to
// be moved. Otherwise, we do not need to move it because a child will be
// inserted or moved before `child`.
if (child._mountIndex < lastIndex) {
return makeMove(child, afterNode, toIndex);
}
}
},

/**
* Creates a child component.
Expand All @@ -453,19 +453,19 @@ class ReactMultiChild {
* @param {string} mountImage Markup to insert.
* @protected
*/
createChild(child, afterNode, mountImage) {
createChild: function(child, afterNode, mountImage) {
return makeInsertMarkup(mountImage, afterNode, child._mountIndex);
}
},

/**
* Removes a child component.
*
* @param {ReactComponent} child Child to remove.
* @protected
*/
removeChild(child, node) {
removeChild: function(child, node) {
return makeRemove(child, node);
}
},

/**
* Mounts a child with the supplied name.
Expand All @@ -478,7 +478,7 @@ class ReactMultiChild {
* @param {ReactReconcileTransaction} transaction
* @private
*/
_mountChildAtIndex(
_mountChildAtIndex: function(
child,
mountImage,
afterNode,
Expand All @@ -487,7 +487,7 @@ class ReactMultiChild {
context) {
child._mountIndex = index;
return this.createChild(child, afterNode, mountImage);
}
},

/**
* Unmounts a rendered child.
Expand All @@ -497,11 +497,11 @@ class ReactMultiChild {
* @param {ReactComponent} child Component to unmount.
* @private
*/
_unmountChild(child, node) {
_unmountChild: function(child, node) {
var update = this.removeChild(child, node);
child._mountIndex = null;
return update;
}
},
};

module.exports = ReactMultiChild;
7 changes: 5 additions & 2 deletions src/renderers/testing/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ function getRenderedHostOrTextFromComponent(component) {
return component;
}

class ReactTestComponent extends ReactMultiChild {
class ReactTestComponent {
_currentElement: ReactElement;
_renderedChildren: null | Object;
_topLevelWrapper: null | ReactInstance;

constructor(element: ReactElement) {
super();
this._currentElement = element;
this._renderedChildren = null;
this._topLevelWrapper = null;
Expand All @@ -67,6 +66,7 @@ class ReactTestComponent extends ReactMultiChild {
context: Object,
) {
var element = this._currentElement;
// $FlowFixMe https://github.com/facebook/flow/issues/1805
this.mountChildren(element.props.children, transaction, context);
}

Expand All @@ -76,6 +76,7 @@ class ReactTestComponent extends ReactMultiChild {
context: Object,
) {
this._currentElement = nextElement;
// $FlowFixMe https://github.com/facebook/flow/issues/1805
this.updateChildren(nextElement.props.children, transaction, context);
}

Expand Down Expand Up @@ -111,6 +112,8 @@ class ReactTestComponent extends ReactMultiChild {
unmountComponent(): void {}
}

Object.assign(ReactTestComponent.prototype, ReactMultiChild);

// =============================================================================

ReactUpdates.injection.injectReconcileTransaction(
Expand Down