mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-05-06 14:32:30 +08:00
15 lines
327 B
JavaScript
15 lines
327 B
JavaScript
export const getElementByXPath = (originXpath, context = document) => {
|
|
try {
|
|
const xpath = originXpath.replace('svg', "*[name()='svg']");
|
|
return document.evaluate(
|
|
xpath,
|
|
context,
|
|
null,
|
|
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
|
null,
|
|
).singleNodeValue;
|
|
} catch (e) {
|
|
console.error(e);
|
|
return null;
|
|
}
|
|
};
|