Skip to content

Commit 8833d87

Browse files
author
Jonathan Felchlin
committed
Fixing "Invalid argument" error in IE 10, when passing undefined to insertAfter
1 parent dcd1f22 commit 8833d87

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

diffDOM.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@
13131313
if (index === 0) {
13141314
reference = node.childNodes[diff[t._const.to]];
13151315
}
1316-
node.insertBefore(childNode, reference);
1316+
node.insertBefore(childNode, reference || null);
13171317
}
13181318
break;
13191319
case this._const.removeElement:
@@ -1323,7 +1323,7 @@
13231323
route = diff[this._const.route].slice();
13241324
c = route.splice(route.length - 1, 1)[0];
13251325
node = this.getFromRoute(tree, route);
1326-
node.insertBefore(this.objToNode(diff[this._const.element], node.namespaceURI === 'http://www.w3.org/2000/svg'), node.childNodes[c]);
1326+
node.insertBefore(this.objToNode(diff[this._const.element], node.namespaceURI === 'http://www.w3.org/2000/svg'), node.childNodes[c] || null);
13271327
break;
13281328
case this._const.removeTextElement:
13291329
if (!node || node.nodeType !== 3) {
@@ -1339,7 +1339,7 @@
13391339
if (!node || !node.childNodes) {
13401340
return false;
13411341
}
1342-
node.insertBefore(newNode, node.childNodes[c]);
1342+
node.insertBefore(newNode, node.childNodes[c] || null);
13431343
break;
13441344
default:
13451345
console.log('unknown action');

0 commit comments

Comments
 (0)