Skip to content

Commit

Permalink
Refactor precacheChildNodes slightly (#8018)
Browse files Browse the repository at this point in the history
This ‘fixes’ a bizarre IE9 script engine issue. #7803
  • Loading branch information
eoin authored and gaearon committed Nov 10, 2016
1 parent fa4710f commit 6ce8f1f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/renderers/dom/shared/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ var Flags = ReactDOMComponentFlags;
var internalInstanceKey =
'__reactInternalInstance$' + Math.random().toString(36).slice(2);

/**
* Check if a given node should be cached.
*/
function shouldPrecacheNode(node, nodeID) {
return (node.nodeType === 1 &&
node.getAttribute(ATTR_NAME) === String(nodeID)) ||
(node.nodeType === 8 &&
node.nodeValue === ' react-text: ' + nodeID + ' ') ||
(node.nodeType === 8 &&
node.nodeValue === ' react-empty: ' + nodeID + ' ');
}

/**
* Drill down (through composites and empty components) until we get a host or
* host text component.
Expand Down Expand Up @@ -87,12 +99,7 @@ function precacheChildNodes(inst, node) {
}
// We assume the child nodes are in the same order as the child instances.
for (; childNode !== null; childNode = childNode.nextSibling) {
if ((childNode.nodeType === 1 &&
childNode.getAttribute(ATTR_NAME) === String(childID)) ||
(childNode.nodeType === 8 &&
childNode.nodeValue === ' react-text: ' + childID + ' ') ||
(childNode.nodeType === 8 &&
childNode.nodeValue === ' react-empty: ' + childID + ' ')) {
if (shouldPrecacheNode(childNode, childID)) {
precacheNode(childInst, childNode);
continue outer;
}
Expand Down

0 comments on commit 6ce8f1f

Please sign in to comment.