mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
fix render order error in safari
This commit is contained in:
@@ -31,10 +31,20 @@ function insertChildAt(parentNode, childNode, index) {
|
||||
// rely exclusively on `insertBefore(node, null)` instead of also using
|
||||
// `appendChild(node)`. However, using `undefined` is not allowed by all
|
||||
// browsers so we must replace it with `null`.
|
||||
parentNode.insertBefore(
|
||||
childNode,
|
||||
parentNode.childNodes[index] || null
|
||||
);
|
||||
|
||||
// fix render order error in safari
|
||||
try {
|
||||
parentNode.insertBefore(
|
||||
childNode,
|
||||
parentNode.childNodes.item(index) || null
|
||||
);
|
||||
} catch (e) {
|
||||
//IE8 can't use `item` when childNodes is empty.
|
||||
parentNode.insertBefore(
|
||||
childNode,
|
||||
parentNode.childNodes[index] || null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user