mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixed a bug in expectRenderedChildAt
React components have _mountIndex, that looks like it is their order in DOM. If you swap 2 elements in DOM, their order in children array isn't changed, but their _mountIndex is
This commit is contained in:
committed by
Paul O’Shannessy
parent
9a13393ce3
commit
385eb1cef1
@@ -73,17 +73,14 @@ mergeInto(reactComponentExpect.prototype, {
|
||||
// change soon.
|
||||
this.toBeDOMComponent();
|
||||
var renderedChildren = this.instance()._renderedChildren || {};
|
||||
var nonEmptyCount = 0;
|
||||
var name;
|
||||
for (name in renderedChildren) {
|
||||
if (!renderedChildren.hasOwnProperty(name)) {
|
||||
continue;
|
||||
}
|
||||
if (renderedChildren[name]) {
|
||||
if (nonEmptyCount === childIndex) {
|
||||
if (renderedChildren[name]._mountIndex === childIndex) {
|
||||
return new reactComponentExpect(renderedChildren[name]);
|
||||
}
|
||||
nonEmptyCount++;
|
||||
}
|
||||
}
|
||||
throw new Error('Child:' + childIndex + ' is not found');
|
||||
|
||||
Reference in New Issue
Block a user