abledom 0.0.5 → 0.1.1

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/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ interface ValidationNotification {
12
12
  message: string;
13
13
  element?: HTMLElement;
14
14
  rel?: Node;
15
- link?: string;
15
+ help?: string;
16
16
  stack?: string[];
17
17
  relStack?: string[];
18
18
  }
package/dist/index.js CHANGED
@@ -100,9 +100,6 @@ var ui_default = "#abledom-report {\n bottom: 20px;\n display: flex;\n flex-d
100
100
 
101
101
  // src/ui/domBuilder.ts
102
102
  var DOMBuilder = class {
103
- // static fromString(parent: HTMLElement | DocumentFragment, html: string): void {
104
- // // const builder = new DOMBuilder(parent);
105
- // }
106
103
  constructor(parent) {
107
104
  __publicField(this, "_doc");
108
105
  __publicField(this, "_stack");
@@ -385,12 +382,20 @@ var _NotificationUI = class _NotificationUI {
385
382
  revealButton.style.display = "none";
386
383
  }
387
384
  }
388
- ).element(reveal_default).closeTag().text(notification.message).openTag("a", {
389
- class: "button close",
390
- href: "/",
391
- title: "Open help",
392
- target: "_blank"
393
- }).element(help_default).closeTag().openTag(
385
+ ).element(reveal_default).closeTag().text(notification.message).openTag(
386
+ "a",
387
+ {
388
+ class: "button close",
389
+ href: notification.help || "/",
390
+ title: "Open help",
391
+ target: "_blank"
392
+ },
393
+ (help) => {
394
+ if (!notification.help) {
395
+ help.style.display = "none";
396
+ }
397
+ }
398
+ ).element(help_default).closeTag().openTag(
394
399
  "button",
395
400
  {
396
401
  class: "button close",
@@ -1318,7 +1323,7 @@ var FocusableElementLabelRule = class extends ValidationRule {
1318
1323
  ).booleanValue;
1319
1324
  }
1320
1325
  _hasLabel(element) {
1321
- var _a, _b;
1326
+ var _a, _b, _c;
1322
1327
  const labels = element.labels;
1323
1328
  if (labels && labels.length > 0) {
1324
1329
  for (let i = 0; i < labels.length; i++) {
@@ -1333,6 +1338,9 @@ var FocusableElementLabelRule = class extends ValidationRule {
1333
1338
  return true;
1334
1339
  }
1335
1340
  }
1341
+ if ((_a = element.textContent) == null ? void 0 : _a.trim()) {
1342
+ return true;
1343
+ }
1336
1344
  const labelNodes = document.evaluate(
1337
1345
  `(
1338
1346
  .//@aria-label |
@@ -1348,7 +1356,7 @@ var FocusableElementLabelRule = class extends ValidationRule {
1348
1356
  null
1349
1357
  );
1350
1358
  for (let i = 0; i < labelNodes.snapshotLength; i++) {
1351
- const val = (_b = (_a = labelNodes.snapshotItem(i)) == null ? void 0 : _a.nodeValue) == null ? void 0 : _b.trim();
1359
+ const val = (_c = (_b = labelNodes.snapshotItem(i)) == null ? void 0 : _b.nodeValue) == null ? void 0 : _c.trim();
1352
1360
  if (val) {
1353
1361
  return true;
1354
1362
  }
@@ -1411,7 +1419,8 @@ var FocusableElementLabelRule = class extends ValidationRule {
1411
1419
  notification: isElementVisible(element) ? {
1412
1420
  id: "focusable-element-label",
1413
1421
  message: "Focusable element must have a non-empty text label.",
1414
- element
1422
+ element,
1423
+ help: "https://www.w3.org/WAI/tutorials/forms/labels/"
1415
1424
  } : void 0,
1416
1425
  dependsOnIds: new Set(labelledByValues)
1417
1426
  };