@samitouri / QOS-React-2 / commits / 54a74d95bb

deal IE8 out of size error

凌恒 committed Apr 1, 2015 at 23:56 UTC 54a74d95bb19a1f1cbe36aeff42f20a302b53658
1 file changed +11 -13
src/browser/ui/dom/DOMChildrenOperations.js
+11 -13
@@ -33,19 +33,17 @@ function insertChildAt(parentNode, childNode, index) {
33 // browsers so we must replace it with `null`.
34
35 // fix render order error in safari
36 - if (!(document.all && !document.addEventListener)) {
37 - parentNode.insertBefore(
38 - childNode,
39 - parentNode.childNodes.item(index) || null
40 - );
41 - } else {
42 - //IE8 can't use `item` when childNodes is empty or dynamic insert.
43 - //But read is well after insert.
44 - parentNode.insertBefore(
45 - childNode,
46 - parentNode.childNodes[index] || null
47 - );
48 - }
36 + // IE8 can't use `item` when childNodes is empty or dynamic insert.
37 + // Because index out of list
38 + // But read is well after insert.
39 + var beforeChild = index >= parentNode.childNodes.length ?
40 + null :
41 + parentNode.childNodes.item(index);
42 +
43 + parentNode.insertBefore(
44 + childNode,
45 + beforeChild
46 + );
47 }
48
49 /**