From f6e5d4394cb89a5d5a3145043c4d4f4717503a69 Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Wed, 30 Oct 2013 12:09:09 -0400 Subject: [PATCH] If parentNode is not correct check for child in childNodes --- src/wrappers/Node.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/wrappers/Node.js b/src/wrappers/Node.js index 1aa4819..0174cac 100644 --- a/src/wrappers/Node.js +++ b/src/wrappers/Node.js @@ -275,8 +275,20 @@ removeChild: function(childWrapper) { assertIsNodeWrapper(childWrapper); if (childWrapper.parentNode !== this) { - // TODO(arv): DOMException - throw new Error('NotFoundError'); + // IE has invalid DOM trees at times. + var found = false; + var childNodes = this.childNodes; + for (var ieChild = this.firstChild; ieChild; + ieChild = ieChild.nextSibling) { + if (ieChild === childWrapper) { + found = true; + break; + } + } + if (!found) { + // TODO(arv): DOMException + throw new Error('NotFoundError'); + } } var childNode = unwrap(childWrapper);