summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-09-18 16:50:12 +0300
committerArtur Signell <artur@vaadin.com>2012-09-18 16:50:12 +0300
commit83a0a0c124e22fdd832f367d79e7d8a0f5605084 (patch)
treec9121be58cb9f430223cee22cb69e89e33b577e8
parent7aafd30a4d2e9c969220e47012d809aeb652f7e8 (diff)
downloadvaadin-framework-83a0a0c124e22fdd832f367d79e7d8a0f5605084.tar.gz
vaadin-framework-83a0a0c124e22fdd832f367d79e7d8a0f5605084.zip
Reverted previous fix and fixed in a more compatible way (#9534)
-rw-r--r--client/src/com/vaadin/client/ComponentLocator.java45
1 files changed, 39 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java
index 8f72fe7289..3338147465 100644
--- a/client/src/com/vaadin/client/ComponentLocator.java
+++ b/client/src/com/vaadin/client/ComponentLocator.java
@@ -97,6 +97,8 @@ public class ComponentLocator {
public String getPathForElement(Element targetElement) {
String pid = null;
+ targetElement = getElement(targetElement);
+
Element e = targetElement;
while (true) {
@@ -178,9 +180,7 @@ public class ComponentLocator {
// 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())) {
+ if (w.getElement() == targetElement) {
/*
* We are done if the target element is the root of the target
* widget.
@@ -210,6 +210,41 @@ public class ComponentLocator {
}
/**
+ * Returns the element passed to the method. Or in case of Firefox 15,
+ * returns the real element that is in the DOM instead of the element passed
+ * to the method (which is the same element but not ==).
+ *
+ * @param targetElement
+ * the element to return
+ * @return the element passed to the method
+ */
+ private Element getElement(Element targetElement) {
+ if (targetElement == null) {
+ return null;
+ }
+
+ if (!BrowserInfo.get().isFirefox()) {
+ return targetElement;
+ }
+
+ if (BrowserInfo.get().getBrowserMajorVersion() != 15) {
+ return targetElement;
+ }
+
+ // Firefox 15, you make me sad
+ if (targetElement.getNextSibling() != null) {
+ return (Element) targetElement.getNextSibling()
+ .getPreviousSibling();
+ }
+ if (targetElement.getPreviousSibling() != null) {
+ return (Element) targetElement.getPreviousSibling()
+ .getNextSibling();
+ }
+ // No siblings so this is the only child
+ return (Element) targetElement.getParentNode().getChild(0);
+ }
+
+ /**
* Finds the first widget in the hierarchy (moving upwards) that implements
* SubPartAware. Returns the SubPartAware implementor or null if none is
* found.
@@ -334,9 +369,7 @@ public class ComponentLocator {
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()) {
+ if (parent == baseElement) {
break;
}