[react_native] JS files from D2163804: [react_native] Add native root tag to createView calls

This commit is contained in:
Andy Street
2015-06-18 05:26:23 -07:00
parent 3fa8ec0271
commit 3029511ce4
4 changed files with 29 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ var warning = require('warning');
* unmount a component with a `rootNodeID`, then mount a new one in its place,
*/
var INITIAL_TAG_COUNT = 1;
var NATIVE_TOP_ROOT_ID_SEPARATOR = '{TOP_LEVEL}';
var ReactNativeTagHandles = {
tagsStartAt: INITIAL_TAG_COUNT,
tagCount: INITIAL_TAG_COUNT,
@@ -67,7 +68,7 @@ var ReactNativeTagHandles = {
this.reactTagIsNativeTopRootID(tag),
'Expect a native root tag, instead got ', tag
);
return '.r[' + tag + ']{TOP_LEVEL}';
return '.r[' + tag + ']' + NATIVE_TOP_ROOT_ID_SEPARATOR;
},
reactTagIsNativeTopRootID: function(reactTag: number): bool {
@@ -75,6 +76,17 @@ var ReactNativeTagHandles = {
return reactTag % 10 === 1;
},
getNativeTopRootIDFromNodeID: function(nodeID: ?string): ?string {
if (!nodeID) {
return null;
}
var index = nodeID.indexOf(NATIVE_TOP_ROOT_ID_SEPARATOR);
if (index === -1) {
return null;
}
return nodeID.substr(0, index + NATIVE_TOP_ROOT_ID_SEPARATOR.length);
},
/**
* Returns the native `nodeHandle` (`tag`) that was most recently *natively*
* mounted at the `rootNodeID`. Just because a React component has been