abledom 0.6.2 → 0.6.3

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/esm/index.js CHANGED
@@ -1058,6 +1058,7 @@ var AbleDOM = class {
1058
1058
  __publicField(this, "_idleResolve");
1059
1059
  __publicField(this, "_currentAnchoredIssues", /* @__PURE__ */ new Map());
1060
1060
  __publicField(this, "_currentNotAnchoredIssues", []);
1061
+ __publicField(this, "_readIssues", /* @__PURE__ */ new Set());
1061
1062
  __publicField(this, "_getHighlighter", () => {
1062
1063
  if (!this._elementHighlighter && !this._isDisposed) {
1063
1064
  this._elementHighlighter = new ElementHighlighter(this._win);
@@ -1417,29 +1418,60 @@ var AbleDOM = class {
1417
1418
  rules.forEach((rule) => this._removeIssue(element, rule));
1418
1419
  });
1419
1420
  }
1420
- _getCurrentIssues() {
1421
- const issues = this._currentNotAnchoredIssues.slice(0);
1421
+ _getCurrentIssues(markAsRead) {
1422
+ const issues = [];
1423
+ this._currentNotAnchoredIssues.forEach((issue) => {
1424
+ if (!this._readIssues.has(issue)) {
1425
+ issues.push(issue);
1426
+ }
1427
+ if (markAsRead) {
1428
+ this._readIssues.add(issue);
1429
+ }
1430
+ });
1422
1431
  this._currentAnchoredIssues.forEach((issueByRule) => {
1423
1432
  issueByRule.forEach((issue) => {
1424
- issues.push(issue);
1433
+ if (!this._readIssues.has(issue)) {
1434
+ issues.push(issue);
1435
+ }
1436
+ if (markAsRead) {
1437
+ this._readIssues.add(issue);
1438
+ }
1425
1439
  });
1426
1440
  });
1427
1441
  return issues;
1428
1442
  }
1429
- idle() {
1443
+ idle(markAsRead, timeout) {
1430
1444
  if (!this._clearValidationTimeout) {
1431
- return Promise.resolve(this._getCurrentIssues());
1432
- }
1445
+ return Promise.resolve(this._getCurrentIssues(!!markAsRead));
1446
+ }
1447
+ let timeoutClear;
1448
+ let timeoutResolve;
1449
+ let timeoutPromise = timeout ? new Promise((resolve) => {
1450
+ timeoutResolve = () => {
1451
+ timeoutClear == null ? void 0 : timeoutClear();
1452
+ timeoutResolve = void 0;
1453
+ resolve(null);
1454
+ };
1455
+ let timeoutTimer = this._win.setTimeout(() => {
1456
+ timeoutClear = void 0;
1457
+ timeoutResolve == null ? void 0 : timeoutResolve();
1458
+ }, timeout);
1459
+ timeoutClear = () => {
1460
+ this._win.clearTimeout(timeoutTimer);
1461
+ timeoutClear = void 0;
1462
+ };
1463
+ }) : void 0;
1433
1464
  if (!this._idlePromise) {
1434
1465
  this._idlePromise = new Promise((resolve) => {
1435
1466
  this._idleResolve = () => {
1436
1467
  delete this._idlePromise;
1437
1468
  delete this._idleResolve;
1438
- resolve(this._getCurrentIssues());
1469
+ resolve(this._getCurrentIssues(!!markAsRead));
1470
+ timeoutResolve == null ? void 0 : timeoutResolve();
1439
1471
  };
1440
1472
  });
1441
1473
  }
1442
- return this._idlePromise;
1474
+ return timeoutPromise ? Promise.race([this._idlePromise, timeoutPromise]) : this._idlePromise;
1443
1475
  }
1444
1476
  clearCurrentIssues(anchored = true, notAnchored = true) {
1445
1477
  if (anchored) {