aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dom_utils.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dom_utils.coffee')
-rw-r--r--lib/dom_utils.coffee8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index a0ac0bd3..8db71001 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -33,13 +33,17 @@ DomUtils =
makeXPath: (elementArray) ->
xpath = []
for element in elementArray
- xpath.push("//" + element, "//xhtml:" + element)
+ xpath.push(".//" + element, ".//xhtml:" + element)
xpath.join(" | ")
+ # Evaluates an XPath on the whole document, or on the contents of the fullscreen element if an element is
+ # fullscreen.
evaluateXPath: (xpath, resultType) ->
+ contextNode =
+ if document.webkitIsFullScreen then document.webkitFullscreenElement else document.documentElement
namespaceResolver = (namespace) ->
if (namespace == "xhtml") then "http://www.w3.org/1999/xhtml" else null
- document.evaluate(xpath, document.documentElement, namespaceResolver, resultType, null)
+ document.evaluate(xpath, contextNode, namespaceResolver, resultType, null)
#
# Returns the first visible clientRect of an element if it exists. Otherwise it returns null.