use ie8 feature detect instead of try catch

This commit is contained in:
凌恒 2015-04-01 21:46:40 +08:00
parent e1a8d69840
commit d4adaee4eb
1 changed files with 4 additions and 3 deletions

View File

@ -33,13 +33,14 @@ function insertChildAt(parentNode, childNode, index) {
// browsers so we must replace it with `null`.
// fix render order error in safari
try {
if (!(document.all && !document.addEventListener)) {
parentNode.insertBefore(
childNode,
parentNode.childNodes.item(index) || null
);
} catch (e) {
//IE8 can't use `item` when childNodes is empty.
} else {
//IE8 can't use `item` when childNodes is empty or dynamic insert.
//But read is well after insert.
parentNode.insertBefore(
childNode,
parentNode.childNodes[index] || null