playwright-ui5 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser/main.js +31 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,4 +35,4 @@ this selector engine uses css selector-like syntax. the main difference is that
|
|
|
35
35
|
| attribute selectors | `[text]`, `[text='foo']`,`[text*='foo']` | ✔ | some equality mods are useless for ui5 (eg. `\|=`) but are supported for the sake of completeness |
|
|
36
36
|
| id selectors | `sap.m.Button#foo` | ✔ | you should not use id selectors if the id is generated (eg. `__button1`) as they can change often |
|
|
37
37
|
| nesting | `sap.m.Table sap.m.Button`,`sap.m.Table > sap.m.Button` | ❌ | use playwright selector nesting instead (`ui5=sap.m.Table >> ui5=sap.m.Button`) |
|
|
38
|
-
| pseudo-classes | `sap.m.Table:has(sap.m.Button)` |
|
|
38
|
+
| pseudo-classes | `sap.m.Table:has(sap.m.Button)` | ✔ | `:has` is supported |
|
package/dist/browser/main.js
CHANGED
|
@@ -1366,24 +1366,15 @@ var parse = (0, import_css_selector_parser.createParser)({
|
|
|
1366
1366
|
namespace: false,
|
|
1367
1367
|
attributes: { operators: ["=", "^=", "$=", "*=", "~=", "|="] },
|
|
1368
1368
|
pseudoElements: false,
|
|
1369
|
+
pseudoClasses: { definitions: { Selector: ["has"] } },
|
|
1369
1370
|
tag: { wildcard: true },
|
|
1370
1371
|
ids: true,
|
|
1371
1372
|
classNames: true
|
|
1372
1373
|
}
|
|
1373
1374
|
});
|
|
1374
|
-
var
|
|
1375
|
+
var queryRule = (root, selector) => {
|
|
1375
1376
|
var _a;
|
|
1376
|
-
const
|
|
1377
|
-
if (selector === "") {
|
|
1378
|
-
throw new Error("ui5 selector is empty");
|
|
1379
|
-
}
|
|
1380
|
-
if (parsedSelector.rules.length > 1) {
|
|
1381
|
-
throw new Error("comma-separated selectors not supported");
|
|
1382
|
-
}
|
|
1383
|
-
if (typeof sap === "undefined") {
|
|
1384
|
-
return [];
|
|
1385
|
-
}
|
|
1386
|
-
const rule = (0, import_throw_expression.throwIfUndefined)(parsedSelector.rules[0], "rules array was empty");
|
|
1377
|
+
const rule = (0, import_throw_expression.throwIfUndefined)(selector.rules[0], "rules array was empty");
|
|
1387
1378
|
if (((_a = rule.tag) == null ? void 0 : _a.type) === "TagName" && rule.classNames) {
|
|
1388
1379
|
const sapNamespace = "sap";
|
|
1389
1380
|
if (rule.tag.name !== sapNamespace) {
|
|
@@ -1424,9 +1415,34 @@ var queryAll = (root, selector) => {
|
|
|
1424
1415
|
)];
|
|
1425
1416
|
});
|
|
1426
1417
|
});
|
|
1427
|
-
return controls.map((control) => control.getDomRef()).filter(
|
|
1428
|
-
(element
|
|
1429
|
-
|
|
1418
|
+
return controls.map((control) => control.getDomRef()).filter((element) => {
|
|
1419
|
+
if (element === null || root.querySelector(`#${element.id}`) === null) {
|
|
1420
|
+
return false;
|
|
1421
|
+
}
|
|
1422
|
+
if (rule.pseudoClasses && queryRule(
|
|
1423
|
+
element,
|
|
1424
|
+
(0, import_throw_expression.throwIfUndefined)(
|
|
1425
|
+
rule.pseudoClasses[0],
|
|
1426
|
+
'":has" pseudo-class was specified without an argument'
|
|
1427
|
+
).argument
|
|
1428
|
+
).length === 0) {
|
|
1429
|
+
return false;
|
|
1430
|
+
}
|
|
1431
|
+
return true;
|
|
1432
|
+
});
|
|
1433
|
+
};
|
|
1434
|
+
var queryAll = (root, selector) => {
|
|
1435
|
+
const parsedSelector = parse(selector);
|
|
1436
|
+
if (selector === "") {
|
|
1437
|
+
throw new Error("ui5 selector is empty");
|
|
1438
|
+
}
|
|
1439
|
+
if (parsedSelector.rules.length > 1) {
|
|
1440
|
+
throw new Error("comma-separated selectors not supported");
|
|
1441
|
+
}
|
|
1442
|
+
if (typeof sap === "undefined") {
|
|
1443
|
+
return [];
|
|
1444
|
+
}
|
|
1445
|
+
return queryRule(root, parsedSelector);
|
|
1430
1446
|
};
|
|
1431
1447
|
var main_default = {
|
|
1432
1448
|
queryAll,
|