mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Refactor precacheChildNodes slightly (#8018)
This ‘fixes’ a bizarre IE9 script engine issue. #7803
This commit is contained in:
committed by
Dan Abramov
parent
a6beb66ffc
commit
9a8f3d922c
@@ -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.
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user