aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core
diff options
context:
space:
mode:
authorjdramaix <julien.dramaix@gmail.com>2012-10-15 12:29:01 +0200
committerjdramaix <julien.dramaix@gmail.com>2012-10-15 12:29:01 +0200
commitbb6cabf555b192aeabdcfc28c114fadb5c7fe612 (patch)
treeab1f8bc7d7b1f0c931668623180b54db2704469e /gwtquery-core
parentd8afa657f09cc139ea41f0f5e646f7bc1b5100a7 (diff)
parenteb0ef954258a36db8fa2fc72c09ac63232e2202a (diff)
downloadgwtquery-bb6cabf555b192aeabdcfc28c114fadb5c7fe612.tar.gz
gwtquery-bb6cabf555b192aeabdcfc28c114fadb5c7fe612.zip
Merge branch 'master' of github.com:gwtquery/gwtquery
Diffstat (limited to 'gwtquery-core')
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java11
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java29
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java9
3 files changed, 39 insertions, 10 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
index 9af3215c..0f07729b 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
@@ -399,6 +399,9 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
// TODO: fix IE link tag serialization
// TODO: fix IE <script> tag
+ // TODO: add fixes for IE TBODY issue
+
+ // We use a temporary element to wrap the elements
Element div = doc.createDivElement();
div.setInnerHTML(wrapper.preWrap + elem.trim() + wrapper.postWrap);
Node n = div;
@@ -406,8 +409,12 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
while (depth-- != 0) {
n = n.getLastChild();
}
- // TODO: add fixes for IE TBODY issue
- return $((NodeList<Element>) n.getChildNodes().cast());
+
+ return
+ // return all nodes added to the wrapper
+ $(n.getChildNodes())
+ // detach nodes from their temporary parent
+ .remove();
}
/**
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java
index 39e8ee09..6fcfca31 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java
@@ -93,16 +93,29 @@ public class DocumentStyleImpl {
name = fixPropertyName(name);
//value defined in the element style
String ret = elem.getStyle().getProperty(name);
-
- if (force && sizeRegex.test(name)) {
- return getVisibleSize(elem, name) + "px";
- }
- if (force && "opacity".equalsIgnoreCase(name)) {
- return String.valueOf(getOpacity(elem));
- }
+
if (force) {
- ret = getComputedStyle(elem, JsUtils.hyphenize(name), name, null);
+ // If the element is dettached to the DOM we attach temporary to it
+ Element parent = null;
+ if (JsUtils.isDettached(elem)) {
+ parent = elem.getParentElement();
+ Document.get().getBody().appendChild(elem);
+ }
+
+ if (sizeRegex.test(name)) {
+ ret = getVisibleSize(elem, name) + "px";
+ } else if ("opacity".equalsIgnoreCase(name)) {
+ ret = String.valueOf(getOpacity(elem));
+ } else {
+ ret = getComputedStyle(elem, JsUtils.hyphenize(name), name, null);
+ }
+
+ // If the element had a parent previously to be attached, append to it.
+ if (parent != null) {
+ parent.appendChild(elem);
+ }
}
+
return ret == null ? "" : ret;
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
index e9649b19..9d384a19 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
@@ -274,6 +274,15 @@ public class JsUtils {
return e.defaultPrevented || e.returnValue === false || e.getPreventDefault
&& e.getPreventDefault() ? true : false;
}-*/;
+
+ /**
+ * Return whether a node is dettached to the dom
+ */
+ public static native boolean isDettached(Node n) /*-{
+ while (n.parentNode)
+ n = n.parentNode;
+ return !n.body;
+ }-*/;
/**
* Check is a javascript object can be cast to an Element