UNPKG

@sap_oss/wdio-qmate-service

Version:

[![REUSE status](https://api.reuse.software/badge/github.com/SAP/wdio-qmate-service)](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[![Node.js CI](https://github.com/SAP/wdio-qmate-service/actions/workflows/node.js.yml/badge.svg)](http

63 lines 2.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UI5ControlDataInjector = void 0; const UI5ControlHandler_1 = require("../utils/UI5ControlHandler"); class UI5ControlDataInjector { static convertAndInjectDataForProperties(controls) { return controls .map((control) => { const domElement = document.getElementById(control.getId?.()); UI5ControlDataInjector.injectDataForProperties(domElement, control); return domElement; }) .filter(Boolean); } static injectDataForProperties(domElement, oControl) { if (!domElement || !oControl) return; UI5ControlDataInjector.injectBindingContextPaths(domElement, oControl); UI5ControlDataInjector.injectAttributes(domElement, oControl, Object.keys(UI5ControlHandler_1.UI5ControlHandler.getControlAllProperties(oControl)), (key) => UI5ControlHandler_1.UI5ControlHandler.getControlProperty(oControl, key)); } static injectAttributes(domElement, oControl, keys, valueGetter) { keys.forEach((key) => { domElement.setAttribute(`data-${key}`, valueGetter(key)); const sBindingDataStr = UI5ControlDataInjector.getBindingInfoDataString(oControl, key); if (sBindingDataStr && sBindingDataStr.trim() !== "") { domElement.setAttribute(`data-${key}-path`, sBindingDataStr); } }); } static injectBindingContextPaths(domElement, oControl) { const aBindingPathValues = UI5ControlHandler_1.UI5ControlHandler.getControlBindingContextPaths(oControl); domElement.setAttribute("data-bindingContextPath-size", aBindingPathValues.length.toString()); aBindingPathValues.forEach((sBindingPathValue, i) => { domElement.setAttribute(`data-bindingContextPath${i}`, sBindingPathValue); }); } static getBindingInfoDataString(oControl, key) { if (!oControl.getBindingInfo?.(key)) return ""; const aBindingInfos = []; const aBindingInfoParts = oControl.getBindingInfo?.(key)?.parts; if (aBindingInfoParts && aBindingInfoParts.length > 0) { for (let i = 0; i < aBindingInfoParts.length; i++) { if (!aBindingInfoParts[i].path) continue; if (aBindingInfoParts[i].model) aBindingInfos.push(aBindingInfoParts[i].model + ">"); aBindingInfos.push(aBindingInfoParts[i].path || ""); } } else { aBindingInfos.push(oControl.getBindingInfo?.(key)?.path || ""); } if (aBindingInfos.length > 0) { return aBindingInfos.join(); } else { return ""; } } } exports.UI5ControlDataInjector = UI5ControlDataInjector; //# sourceMappingURL=UI5ControlDataInjector.js.map