@samitouri / QOS-React / commits / 6ce8f1f93c

Refactor `precacheChildNodes` slightly (#8018)

This ‘fixes’ a bizarre IE9 script engine issue. #7803

Eoin Hennessy committed Nov 10, 2016 at 16:02 UTC 6ce8f1f93c1d8758fcaa819ab18c70a7dd65b6aa
1 file changed +13 -6
src/renderers/dom/shared/ReactDOMComponentTree.js
+13 -6
@@ -22,6 +22,18 @@ var Flags = ReactDOMComponentFlags;
22 var internalInstanceKey =
23 '__reactInternalInstance$' + Math.random().toString(36).slice(2);
24
25 +/**
26 + * Check if a given node should be cached.
27 + */
28 +function shouldPrecacheNode(node, nodeID) {
29 + return (node.nodeType === 1 &&
30 + node.getAttribute(ATTR_NAME) === String(nodeID)) ||
31 + (node.nodeType === 8 &&
32 + node.nodeValue === ' react-text: ' + nodeID + ' ') ||
33 + (node.nodeType === 8 &&
34 + node.nodeValue === ' react-empty: ' + nodeID + ' ');
35 +}
36 +
37 /**
38 * Drill down (through composites and empty components) until we get a host or
39 * host text component.
@@ -87,12 +99,7 @@ function precacheChildNodes(inst, node) {
99 }
100 // We assume the child nodes are in the same order as the child instances.
101 for (; childNode !== null; childNode = childNode.nextSibling) {
90 - if ((childNode.nodeType === 1 &&
91 - childNode.getAttribute(ATTR_NAME) === String(childID)) ||
92 - (childNode.nodeType === 8 &&
93 - childNode.nodeValue === ' react-text: ' + childID + ' ') ||
94 - (childNode.nodeType === 8 &&
95 - childNode.nodeValue === ' react-empty: ' + childID + ' ')) {
102 + if (shouldPrecacheNode(childNode, childID)) {
103 precacheNode(childInst, childNode);
104 continue outer;
105 }