one-click-accessibility/modules/scanner/assets/js/utils/get-element-by-xpath.js
Raz Ohad d07cb63d38
POC - FrontEnd remediations to handle Dynamic Data [APP-1644] (#312)
* POC - FrontEnd remediations to handle Dynamic Data

* Update modules/remediation/components/remediation-runner.php

Co-authored-by: gitstream-cm[bot] <111687743+gitstream-cm[bot]@users.noreply.github.com>

* added MutationObserver to cover elements that are added later on the page

runs until remediations are all done, and disconnect

* added $use_frontend flag instead of using "false"

* Update modules/remediation/components/remediation-runner.php

Co-authored-by: gitstream-cm[bot] <111687743+gitstream-cm[bot]@users.noreply.github.com>

* WIP on poc/fe-remediations

* [APP-0000] call trigger save async

* [APP-1644] apply FE remediation

* [APP-1644] apply FE remediation

* [APP-1644] apply FE remediation

* Add timeout (wait for FE remediation timeout)

* Add timeout (wait for FE remediation timeout)

* Add timeout (wait for FE remediation timeout)

* Add timeout (wait for FE remediation timeout)

* Add timeout (wait for FE remediation timeout)

* Small fixes

* Small fixes

* Small fixes

* Small fixes

---------

Co-authored-by: gitstream-cm[bot] <111687743+gitstream-cm[bot]@users.noreply.github.com>
Co-authored-by: vasyldinets <vasyld@elementor.red>
2025-07-03 17:26:50 +02:00

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;
}
};