@samitouri / QOS-React-2 / commits / e1a8d69840

fix render order error in safari

凌恒 committed Apr 1, 2015 at 18:13 UTC e1a8d6984066f7c2eafab4ed7953361035b640e7
1 file changed +14 -4
src/browser/ui/dom/DOMChildrenOperations.js
+14 -4
@@ -31,10 +31,20 @@ function insertChildAt(parentNode, childNode, index) {
31 // rely exclusively on `insertBefore(node, null)` instead of also using
32 // `appendChild(node)`. However, using `undefined` is not allowed by all
33 // browsers so we must replace it with `null`.
34 - parentNode.insertBefore(
35 - childNode,
36 - parentNode.childNodes[index] || null
37 - );
34 +
35 + // fix render order error in safari
36 + try {
37 + parentNode.insertBefore(
38 + childNode,
39 + parentNode.childNodes.item(index) || null
40 + );
41 + } catch (e) {
42 + //IE8 can't use `item` when childNodes is empty.
43 + parentNode.insertBefore(
44 + childNode,
45 + parentNode.childNodes[index] || null
46 + );
47 + }
48 }
49
50 /**