mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-27 04:15:38 +08:00
14 lines
258 B
JavaScript
14 lines
258 B
JavaScript
export const getElementByXPath = (xpath, context = document) => {
|
|
try {
|
|
return document.evaluate(
|
|
xpath,
|
|
context,
|
|
null,
|
|
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
|
null,
|
|
).singleNodeValue;
|
|
} catch (e) {
|
|
console.error(e);
|
|
return null;
|
|
}
|
|
};
|