aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/SelectorEngine.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/SelectorEngine.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/SelectorEngine.java
index 41f9a685..acf2437f 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/SelectorEngine.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/SelectorEngine.java
@@ -73,7 +73,9 @@ public class SelectorEngine {
public static native NodeList<Element> xpathEvaluate(String selector,
Node ctx, JSArray r) /*-{
var node;
- var result = $doc.evaluate(selector, ctx, null, 0, null);
+ var ownerDoc = ctx && (ctx.ownerDocument || ctx );
+ var evalDoc = ownerDoc ? ownerDoc : $doc;
+ var result = evalDoc.evaluate(selector, ctx, null, 0, null);
while ((node = result.iterateNext())) {
r.push(node);
}