(xpath, contextNode, doc = document)
| 2349 | return [].slice.call(contextNode.querySelectorAll(css)); |
| 2350 | } |
| 2351 | function getXpath(xpath, contextNode, doc = document) { |
| 2352 | contextNode = contextNode || doc; |
| 2353 | try { |
| 2354 | const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); |
| 2355 | // 应该总是返回一个元素节点 |
| 2356 | return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue; |
| 2357 | } catch (err) { |
| 2358 | throw new Error(`无效 Xpath: ${xpath}`); |
| 2359 | } |
| 2360 | } |
| 2361 | function getAllXpath(xpath, contextNode, doc = document) { |
| 2362 | contextNode = contextNode || doc; |
| 2363 | const result = []; |
no outgoing calls
no test coverage detected