Allow accessing siblings by ref

This makes it possible to write a wider range of components without
depending on internal implementations.
This commit is contained in:
CommitSyncScript
2013-06-21 16:02:57 -07:00
committed by Paul O’Shannessy
parent 36a724feca
commit 2bc2b52eaa
+16
View File
@@ -564,6 +564,22 @@ var ReactComponent = {
*/
isOwnedBy: function(owner) {
return this.props[OWNER] === owner;
},
/**
* Gets another component, that shares the same owner as this one, by ref.
*
* @param {string} ref of a sibling Component.
* @return {?ReactComponent} the actual sibling Component.
* @final
* @internal
*/
getSiblingByRef: function(ref) {
var owner = this.props[OWNER];
if (!owner || !owner.refs) {
return null;
}
return owner.refs[ref];
}
}