From: Artur Signell Date: Tue, 18 Sep 2012 13:20:56 +0000 (+0300) Subject: Workaround for Firefox 15 element comparsion issue (#9534) X-Git-Tag: 7.0.0.beta2~68 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7aafd30a4d2e9c969220e47012d809aeb652f7e8;p=vaadin-framework.git Workaround for Firefox 15 element comparsion issue (#9534) --- diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index 1852b67260..8f72fe7289 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -176,7 +176,11 @@ public class ComponentLocator { return null; } - if (w.getElement() == targetElement) { + // The parent check is a work around for Firefox 15 which fails to + // compare elements properly (#9534) + if (w.getElement() == targetElement + || (w.getElement().getParentElement() == targetElement + .getParentElement())) { /* * We are done if the target element is the root of the target * widget. @@ -316,28 +320,23 @@ public class ComponentLocator { Element e = element; String path = ""; while (true) { - Element parent = DOM.getParent(e); - if (parent == null) { - return null; - } - int childIndex = -1; - - int childCount = DOM.getChildCount(parent); - for (int i = 0; i < childCount; i++) { - if (e == DOM.getChild(parent, i)) { - childIndex = i; - break; - } - } - if (childIndex == -1) { - return null; + Element siblingIterator = e; + while (siblingIterator != null) { + childIndex++; + siblingIterator = siblingIterator.getPreviousSiblingElement() + .cast(); } path = PARENTCHILD_SEPARATOR + "domChild[" + childIndex + "]" + path; - if (parent == baseElement) { + Element parent = e.getParentElement().cast(); + // The parent check is a work around for Firefox 15 which fails to + // compare elements properly (#9534) + if (parent == baseElement + || parent.getParentElement() == baseElement + .getParentElement()) { break; }