@sap_oss/wdio-qmate-service
Version:
[](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[](http
28 lines • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DomPropertiesComparator = void 0;
const Comparator_1 = require("./Comparator");
class DomPropertiesComparator {
static compareToDomProperties(properties, control) {
const node = document.getElementById(control.getId?.());
if (!properties || !node || typeof properties !== "object") {
return true;
}
const nodeAttributes = DomPropertiesComparator.retrieveNodeAttributes(node);
return Object.entries(properties).every(([key, value]) => {
if (key === "nodeName") {
return Comparator_1.Comparator.compareWithWildCard(node?.nodeName, value, true);
}
const valueArray = Array.isArray(value) ? value : [value];
return valueArray.every(val => DomPropertiesComparator.compareAttributeToElementAttributes(key, val, nodeAttributes));
});
}
static retrieveNodeAttributes(node) {
return new Map(Array.from(node.attributes, a => [a.nodeName, a.nodeValue ?? ""]));
}
static compareAttributeToElementAttributes(key, value, nodeAttributes) {
return Comparator_1.Comparator.compareWithWildCard(value, nodeAttributes.get(key));
}
}
exports.DomPropertiesComparator = DomPropertiesComparator;
//# sourceMappingURL=DomPropertiesComparator.js.map