(element, useAttributes)
| 120 | }; |
| 121 | |
| 122 | var buildPath = function(element, useAttributes) { |
| 123 | var path = getElementString(element, useAttributes); |
| 124 | if (!path) { |
| 125 | return ''; |
| 126 | } |
| 127 | var parent = element.parentNode; |
| 128 | |
| 129 | while (parent && parent.tagName) { |
| 130 | if (!useAttributes) { |
| 131 | if (element.id !== "") { |
| 132 | return "//" + element.tagName.toLowerCase() + "[@id='" + element.id + "']"; |
| 133 | } |
| 134 | if (parent.id !== "") { |
| 135 | return "//" + parent.tagName.toLowerCase() + "[@id='" + parent.id + "']/" + path; |
| 136 | } |
| 137 | } |
| 138 | path = getElementString(parent, useAttributes) + "/" + path; |
| 139 | parent = parent.parentNode; |
| 140 | } |
| 141 | |
| 142 | return path.replace(/^((\/){0,2}html)/, "/html"); |
| 143 | }; |
| 144 | |
| 145 | return buildPath(element, useAttributes); |
| 146 | } |
no test coverage detected