/** * Finds the node with the supplied React-generated DOM ID. * * @param {string} id A React-generated DOM ID. * @return {?DOMElement} DOM node with the suppled `id`. * @internal */ function getNode(id) { if (!nodeCache.hasOwnProperty(id)) { nodeCache[id] = document.getElementById(id) || // TODO Quit using getElementById. ReactMount.findReactRenderedDOMNodeSlow(id); } var node = nodeCache[id]; if (getID(node) === id) { return node; } return null; }
getDOMNode: function() { invariant( ExecutionEnvironment.canUseDOM, 'getDOMNode(): The DOM is not supported in the current environment.' ); invariant( this._lifeCycleState === ComponentLifeCycle.MOUNTED, 'getDOMNode(): A component must be mounted to have a DOM node.' ); var rootNode = this._rootNode; if (!rootNode) { rootNode = document.getElementById(this._rootNodeID); if (!rootNode) { // TODO: Log the frequency that we reach this path. rootNode = ReactMount.findReactRenderedDOMNodeSlow(this._rootNodeID); } this._rootNode = rootNode; } return rootNode; },
getCachedNodeByID: function(id) { return nodeCache[id] || (nodeCache[id] = document.getElementById(id) || ReactMount.findReactRenderedDOMNodeSlow(id)); }