Minor dependency updates
[yaffs-website] / vendor / jcalderonzumba / mink-phantomjs-driver / src / Resources / Script / is_checked.js.twig
1 {% autoescape 'js' %}
2 (function (xpath) {
3   function getElement(xpath, within) {
4     var result;
5     if (within === null || within === undefined) {
6       within = document;
7     }
8     result = document.evaluate(xpath, within, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
9     if (result.snapshotLength !== 1) {
10       return null;
11     }
12     return result.snapshotItem(0);
13   }
14
15   var node = getElement(xpath);
16
17   if (node === null) {
18     return null;
19   }
20
21   if(node.tagName.toLowerCase() != "input"){
22     return null;
23   }
24
25   if(node.type.toLowerCase() != "checkbox" && node.type.toLowerCase() != "radio"){
26     return null;
27   }
28
29   return node.checked;
30 }('{{ xpath }}'));
31 {% endautoescape %}