@uuv/a11y 1.0.0-beta.3 → 1.0.0-beta.30

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +241 -0
  2. package/CONTRIBUTING.md +46 -0
  3. package/LICENSE +1 -1
  4. package/README.md +32 -249
  5. package/STRUCTURE.md +10 -0
  6. package/bundle/uuv-a11y.bundle.js +2 -2
  7. package/dist/CHANGELOG.md +240 -0
  8. package/dist/CONTRIBUTING.md +46 -0
  9. package/dist/README.md +32 -249
  10. package/dist/STRUCTURE.md +10 -0
  11. package/dist/lib/engine/engine.js +28 -16
  12. package/dist/lib/model/index.d.ts +1 -1
  13. package/dist/lib/model/index.js +1 -1
  14. package/dist/lib/model/reference.js +1 -1
  15. package/dist/lib/model/result.d.ts +2 -1
  16. package/dist/lib/model/result.js +1 -1
  17. package/dist/lib/model/rule.d.ts +0 -7
  18. package/dist/lib/model/rule.js +3 -5
  19. package/dist/lib/query/00-query.d.ts +6 -1
  20. package/dist/lib/query/00-query.js +10 -0
  21. package/dist/lib/query/accessible-name.query.d.ts +4 -2
  22. package/dist/lib/query/accessible-name.query.js +9 -3
  23. package/dist/lib/query/by-role.query.d.ts +4 -3
  24. package/dist/lib/query/by-role.query.js +22 -6
  25. package/dist/lib/query/by-sibling.query.d.ts +12 -0
  26. package/dist/lib/query/by-sibling.query.js +100 -0
  27. package/dist/lib/query/by-tag.query.d.ts +2 -2
  28. package/dist/lib/query/by-tag.query.js +2 -1
  29. package/dist/lib/query/compliant-attributes/attribut-specification.d.ts +34 -0
  30. package/dist/lib/query/compliant-attributes/attribut-specification.js +96 -0
  31. package/dist/lib/query/compliant-attributes/attribute-checker.d.ts +47 -0
  32. package/dist/lib/query/compliant-attributes/attribute-checker.js +73 -0
  33. package/dist/lib/query/compliant-attributes/compliant-attributes.query.d.ts +9 -0
  34. package/dist/lib/query/compliant-attributes/compliant-attributes.query.js +24 -0
  35. package/dist/lib/query/doctype.query.d.ts +2 -2
  36. package/dist/lib/query/doctype.query.js +2 -1
  37. package/dist/lib/query/form.query.d.ts +2 -2
  38. package/dist/lib/query/index.d.ts +7 -0
  39. package/dist/lib/query/index.js +7 -0
  40. package/dist/lib/query/operators/and-query.d.ts +8 -0
  41. package/dist/lib/query/operators/and-query.js +25 -0
  42. package/dist/lib/query/operators/operator-query.d.ts +8 -0
  43. package/dist/lib/query/operators/operator-query.js +14 -0
  44. package/dist/lib/query/operators/or-query.d.ts +8 -0
  45. package/dist/lib/query/operators/or-query.js +24 -0
  46. package/dist/lib/reference/rgaa/coverage/coverage-statement.json +56 -17
  47. package/dist/lib/reference/rgaa/rules/1-image.d.ts +0 -1
  48. package/dist/lib/reference/rgaa/rules/1-image.js +51 -77
  49. package/dist/lib/reference/rgaa/rules/11-form.d.ts +0 -1
  50. package/dist/lib/reference/rgaa/rules/11-form.js +0 -1
  51. package/dist/lib/reference/rgaa/rules/2-frame.d.ts +0 -1
  52. package/dist/lib/reference/rgaa/rules/2-frame.js +8 -7
  53. package/dist/lib/reference/rgaa/rules/3-color.d.ts +0 -1
  54. package/dist/lib/reference/rgaa/rules/3-color.js +0 -3
  55. package/dist/lib/reference/rgaa/rules/5-table.d.ts +12 -1
  56. package/dist/lib/reference/rgaa/rules/5-table.js +292 -1
  57. package/dist/lib/reference/rgaa/rules/6-link.d.ts +12 -1
  58. package/dist/lib/reference/rgaa/rules/6-link.js +147 -1
  59. package/dist/lib/reference/rgaa/rules/8-required-element.d.ts +0 -1
  60. package/dist/lib/reference/rgaa/rules/8-required-element.js +57 -9
  61. package/dist/lib/reference/rgaa/selector-helper.d.ts +40 -1
  62. package/dist/lib/reference/rgaa/selector-helper.js +82 -10
  63. package/dist/package.json +15 -6
  64. package/package.json +15 -6
@@ -18,13 +18,14 @@ class Engine {
18
18
  observer.complete();
19
19
  });
20
20
  }
21
- getRuleResult(rule, foundElements) {
21
+ getRuleResult(rule, queryResults) {
22
22
  if (rule.check === model_1.RuleCheckEnum.MANUAL) {
23
- return this.buildResultForManualCheck(rule, foundElements);
23
+ return this.buildResultForManualCheck(rule, queryResults);
24
24
  }
25
25
  else {
26
26
  // Then we are considering rule as RuleCheckEnum.AUTO
27
- return this.buildResultForAutoCheck(rule, foundElements);
27
+ const domNodes = queryResults.map((element) => element.domNode);
28
+ return this.buildResultForAutoCheck(rule, domNodes);
28
29
  }
29
30
  }
30
31
  buildResultForAutoCheck(rule, $el) {
@@ -62,30 +63,41 @@ class Engine {
62
63
  }
63
64
  return a11YRuleresult;
64
65
  }
65
- buildResultForManualCheck(rule, $el) {
66
- const a11YRuleresult = new model_1.A11yRuleResult(this.targetUrl, rule);
67
- const validation = a11YRuleresult.getOrAddValidation(rule.criterion);
66
+ buildResultForManualCheck(rule, queryResults) {
67
+ const a11YRuleResult = new model_1.A11yRuleResult(this.targetUrl, rule);
68
+ const validation = a11YRuleResult.getOrAddValidation(rule.criterion);
68
69
  validation.status = model_1.A11yResultStatus.SUCCESS;
69
- for (let i = 0; i < $el.length; i++) {
70
- const selector = this.getSelector($el[i]);
70
+ for (const element of queryResults) {
71
+ const domNode = element.domNode;
72
+ const selector = this.getSelector(domNode);
71
73
  const attributesToCheck = [];
72
74
  rule.attributes.forEach((attribute) => {
73
- const attributeFilledWithInformation = $el[i].getAttribute(attribute);
74
- if (attributeFilledWithInformation) {
75
- attributesToCheck.push(` ${attribute}=${attributeFilledWithInformation}`);
75
+ const childData = attribute.split(":");
76
+ if (childData.length > 1) {
77
+ domNode.childNodes.forEach((childNode) => {
78
+ if (childNode.nodeName === childData[1]) {
79
+ attributesToCheck.push(`${attribute}=${childNode.textContent}`);
80
+ }
81
+ });
82
+ }
83
+ else {
84
+ const attributeFilledWithInformation = domNode.getAttribute(attribute);
85
+ if (attributeFilledWithInformation) {
86
+ attributesToCheck.push(`${attribute}=${attributeFilledWithInformation}`);
87
+ }
76
88
  }
77
89
  });
78
- const manualValidation = a11YRuleresult.getOrAddValidation(rule.criterion);
90
+ const manualValidation = a11YRuleResult.getOrAddValidation(rule.criterion);
79
91
  manualValidation.status = model_1.A11yResultStatus.MANUAL;
80
92
  manualValidation.nodesToCheckManually.push({
81
- node: $el[i],
93
+ node: element,
82
94
  selector: selector,
83
- attributes: attributesToCheck.toString(),
84
- html: $el[i].outerHTML,
95
+ attributes: attributesToCheck.join(", "),
96
+ html: domNode.outerHTML,
85
97
  help: rule.id ? `${this.reference.getRuleUrl(rule.id)}` : ""
86
98
  });
87
99
  }
88
- return a11YRuleresult;
100
+ return a11YRuleResult;
89
101
  }
90
102
  getSelector(element) {
91
103
  const path = [];
@@ -1,4 +1,4 @@
1
- export * from "./checker";
2
1
  export * from "./reference";
2
+ export * from "./checker";
3
3
  export * from "./result";
4
4
  export * from "./rule";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./checker"), exports);
18
17
  __exportStar(require("./reference"), exports);
18
+ __exportStar(require("./checker"), exports);
19
19
  __exportStar(require("./result"), exports);
20
20
  __exportStar(require("./rule"), exports);
@@ -7,7 +7,7 @@ var A11yReferenceEnum;
7
7
  A11yReferenceEnum["WCAG_WEB"] = "WCAG-WEB";
8
8
  A11yReferenceEnum["WCAG_ANDROID"] = "WCAG-ANDROID";
9
9
  A11yReferenceEnum["WCAG_IOS"] = "WCAG-IOS";
10
- })(A11yReferenceEnum = exports.A11yReferenceEnum || (exports.A11yReferenceEnum = {}));
10
+ })(A11yReferenceEnum || (exports.A11yReferenceEnum = A11yReferenceEnum = {}));
11
11
  class Comments {
12
12
  info;
13
13
  warning;
@@ -1,5 +1,6 @@
1
1
  import { A11yRule } from "./rule";
2
2
  import { A11yReference } from "./reference";
3
+ import { QueryResult } from "../query";
3
4
  export declare enum A11yResultStatus {
4
5
  UNKNOWN = "unknown",
5
6
  SUCCESS = "success",
@@ -12,7 +13,7 @@ export interface NonCompliantNode {
12
13
  html?: string;
13
14
  }
14
15
  export interface NodeToCheckManually {
15
- node: HTMLElement;
16
+ node: QueryResult;
16
17
  selector: string;
17
18
  attributes: string;
18
19
  html: string;
@@ -7,7 +7,7 @@ var A11yResultStatus;
7
7
  A11yResultStatus["SUCCESS"] = "success";
8
8
  A11yResultStatus["MANUAL"] = "manual";
9
9
  A11yResultStatus["ERROR"] = "error";
10
- })(A11yResultStatus = exports.A11yResultStatus || (exports.A11yResultStatus = {}));
10
+ })(A11yResultStatus || (exports.A11yResultStatus = A11yResultStatus = {}));
11
11
  class A11yRuleValidationResult {
12
12
  criteria;
13
13
  status = A11yResultStatus.UNKNOWN;
@@ -1,7 +1,6 @@
1
1
  import { Query } from "../query/00-query";
2
2
  export interface A11yRule {
3
3
  attributes: string[];
4
- reference: string;
5
4
  check: RuleCheckEnum;
6
5
  criterion: string;
7
6
  wcag: string;
@@ -14,7 +13,6 @@ export interface A11yRule {
14
13
  }
15
14
  export declare class AutoCheckA11yRule implements A11yRule {
16
15
  attributes: string[];
17
- reference: string;
18
16
  check: RuleCheckEnum;
19
17
  criterion: string;
20
18
  wcag: string;
@@ -26,7 +24,6 @@ export declare class AutoCheckA11yRule implements A11yRule {
26
24
  shouldNotExist: boolean;
27
25
  static from(input: {
28
26
  attributes?: string[];
29
- reference: string;
30
27
  criterion: string;
31
28
  wcag: string;
32
29
  id: string;
@@ -37,7 +34,6 @@ export declare class AutoCheckA11yRule implements A11yRule {
37
34
  shouldNotExist?: boolean;
38
35
  }): AutoCheckA11yRule & {
39
36
  attributes?: string[] | undefined;
40
- reference: string;
41
37
  criterion: string;
42
38
  wcag: string;
43
39
  id: string;
@@ -50,7 +46,6 @@ export declare class AutoCheckA11yRule implements A11yRule {
50
46
  }
51
47
  export declare class ManualCheckA11yRule implements A11yRule {
52
48
  attributes: string[];
53
- reference: string;
54
49
  check: RuleCheckEnum;
55
50
  criterion: string;
56
51
  wcag: string;
@@ -62,7 +57,6 @@ export declare class ManualCheckA11yRule implements A11yRule {
62
57
  shouldNotExist: boolean;
63
58
  static from(input: {
64
59
  attributes?: string[];
65
- reference: string;
66
60
  criterion: string;
67
61
  wcag: string;
68
62
  id: string;
@@ -73,7 +67,6 @@ export declare class ManualCheckA11yRule implements A11yRule {
73
67
  shouldNotExist?: boolean;
74
68
  }): ManualCheckA11yRule & {
75
69
  attributes?: string[] | undefined;
76
- reference: string;
77
70
  criterion: string;
78
71
  wcag: string;
79
72
  id: string;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RuleTypeEnum = exports.CustomFilter = exports.RuleCheckEnum = exports.ManualCheckA11yRule = exports.AutoCheckA11yRule = void 0;
4
4
  class AutoCheckA11yRule {
5
5
  attributes;
6
- reference;
7
6
  check = RuleCheckEnum.AUTO;
8
7
  criterion;
9
8
  wcag;
@@ -20,7 +19,6 @@ class AutoCheckA11yRule {
20
19
  exports.AutoCheckA11yRule = AutoCheckA11yRule;
21
20
  class ManualCheckA11yRule {
22
21
  attributes = [];
23
- reference;
24
22
  check = RuleCheckEnum.MANUAL;
25
23
  criterion;
26
24
  wcag;
@@ -39,15 +37,15 @@ var RuleCheckEnum;
39
37
  (function (RuleCheckEnum) {
40
38
  RuleCheckEnum["MANUAL"] = "MANUAL";
41
39
  RuleCheckEnum["AUTO"] = "AUTO";
42
- })(RuleCheckEnum = exports.RuleCheckEnum || (exports.RuleCheckEnum = {}));
40
+ })(RuleCheckEnum || (exports.RuleCheckEnum = RuleCheckEnum = {}));
43
41
  var CustomFilter;
44
42
  (function (CustomFilter) {
45
43
  CustomFilter["DOCTYPE"] = "$DOCTYPE";
46
44
  CustomFilter["FORM_FIELD"] = "$FORMFIELD";
47
- })(CustomFilter = exports.CustomFilter || (exports.CustomFilter = {}));
45
+ })(CustomFilter || (exports.CustomFilter = CustomFilter = {}));
48
46
  var RuleTypeEnum;
49
47
  (function (RuleTypeEnum) {
50
48
  RuleTypeEnum["TAG"] = "TAG";
51
49
  RuleTypeEnum["ROLE"] = "ROLE";
52
50
  RuleTypeEnum["COLOR"] = "COLOR";
53
- })(RuleTypeEnum = exports.RuleTypeEnum || (exports.RuleTypeEnum = {}));
51
+ })(RuleTypeEnum || (exports.RuleTypeEnum = RuleTypeEnum = {}));
@@ -1,4 +1,9 @@
1
1
  export interface Query {
2
- execute(): HTMLElement[];
2
+ execute(): QueryResult[];
3
3
  getSelector(): string;
4
4
  }
5
+ export declare class QueryResult {
6
+ readonly domNode: HTMLElement;
7
+ readonly linkedNodes: HTMLElement[];
8
+ constructor(domNode: HTMLElement, linkedNodes?: HTMLElement[]);
9
+ }
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryResult = void 0;
4
+ class QueryResult {
5
+ domNode;
6
+ linkedNodes;
7
+ constructor(domNode, linkedNodes = []) {
8
+ this.domNode = domNode;
9
+ this.linkedNodes = linkedNodes;
10
+ }
11
+ }
12
+ exports.QueryResult = QueryResult;
@@ -1,8 +1,10 @@
1
- import { Query } from "./00-query";
1
+ import { Query, QueryResult } from "./00-query";
2
2
  export declare class AccessibleNameQuery implements Query {
3
3
  readonly subQuery: Query;
4
4
  readonly shouldBeEmpty: boolean;
5
5
  constructor(subQuery: Query, shouldBeEmpty: boolean);
6
- execute(): HTMLElement[];
6
+ execute(): QueryResult[];
7
+ private isNullOrEmpty;
8
+ private isNotNullAndNotEmpty;
7
9
  getSelector(): string;
8
10
  }
@@ -12,11 +12,11 @@ class AccessibleNameQuery {
12
12
  }
13
13
  execute() {
14
14
  return this.subQuery.execute().filter(element => {
15
- const accessibleName = (0, dom_accessibility_api_1.computeAccessibleName)(element);
16
- if (this.shouldBeEmpty && (0, lodash_1.isEmpty)(accessibleName)) {
15
+ const accessibleName = (0, dom_accessibility_api_1.computeAccessibleName)(element.domNode);
16
+ if (this.shouldBeEmpty && this.isNullOrEmpty(accessibleName)) {
17
17
  return true;
18
18
  }
19
- else if (!this.shouldBeEmpty && !(0, lodash_1.isEmpty)(accessibleName)) {
19
+ else if (!this.shouldBeEmpty && this.isNotNullAndNotEmpty(accessibleName)) {
20
20
  return true;
21
21
  }
22
22
  else {
@@ -24,6 +24,12 @@ class AccessibleNameQuery {
24
24
  }
25
25
  });
26
26
  }
27
+ isNullOrEmpty(accessibleName) {
28
+ return (0, lodash_1.isNull)(accessibleName) || (0, lodash_1.isEmpty)(accessibleName);
29
+ }
30
+ isNotNullAndNotEmpty(accessibleName) {
31
+ return !(0, lodash_1.isNull)(accessibleName) && !(0, lodash_1.isEmpty)(accessibleName);
32
+ }
27
33
  getSelector() {
28
34
  return `AccessibleName: ${this.subQuery.getSelector()}`;
29
35
  }
@@ -1,8 +1,9 @@
1
- import { Query } from "./00-query";
1
+ import { Query, QueryResult } from "./00-query";
2
2
  export declare class ByRoleQuery implements Query {
3
3
  readonly role: string;
4
4
  readonly attributes: string[];
5
- constructor(role: string, attributes?: string[]);
6
- execute(): HTMLElement[];
5
+ readonly excludedTags: string[];
6
+ constructor(role: string, attributes?: string[], excludedTags?: string[]);
7
+ execute(): QueryResult[];
7
8
  getSelector(): string;
8
9
  }
@@ -1,27 +1,43 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ByRoleQuery = void 0;
7
+ const _00_query_1 = require("./00-query");
4
8
  const dom_1 = require("@testing-library/dom");
9
+ const lodash_1 = __importDefault(require("lodash"));
5
10
  class ByRoleQuery {
6
11
  role;
7
12
  attributes;
8
- constructor(role, attributes = []) {
13
+ excludedTags;
14
+ constructor(role, attributes = [], excludedTags = []) {
9
15
  this.role = role;
10
16
  this.attributes = attributes;
17
+ this.excludedTags = excludedTags;
11
18
  }
12
19
  execute() {
13
20
  return (0, dom_1.queryAllByRole)(window.document.documentElement, this.role)
14
21
  ?.filter((element) => {
15
- if (this.attributes.length == 0) {
22
+ if (lodash_1.default.isEmpty(this.attributes) && lodash_1.default.isEmpty(this.excludedTags)) {
16
23
  return true;
17
24
  }
18
- return this.attributes.filter(value => {
25
+ const foundExcludedTags = this.excludedTags.filter(value => {
26
+ return element.tagName.toLowerCase() === value;
27
+ });
28
+ const foundAttributes = this.attributes.filter(value => {
19
29
  return element.getAttribute(value);
20
- }).length > 0;
21
- });
30
+ });
31
+ const hasFoundExcludedTags = !lodash_1.default.isEmpty(this.excludedTags) && !lodash_1.default.isEmpty(foundExcludedTags);
32
+ const hasFoundAttributes = !lodash_1.default.isEmpty(this.attributes) && !lodash_1.default.isEmpty(foundAttributes);
33
+ return (!hasFoundExcludedTags &&
34
+ hasFoundAttributes) ||
35
+ lodash_1.default.isEmpty(this.excludedTags) && hasFoundAttributes ||
36
+ lodash_1.default.isEmpty(this.attributes) && !hasFoundExcludedTags;
37
+ }).map((element) => new _00_query_1.QueryResult(element));
22
38
  }
23
39
  getSelector() {
24
- return `ByRole(${this.role}, ${this.attributes})`;
40
+ return `ByRole(${this.role}, ${this.excludedTags}, ${this.attributes})`;
25
41
  }
26
42
  }
27
43
  exports.ByRoleQuery = ByRoleQuery;
@@ -0,0 +1,12 @@
1
+ import { Query, QueryResult } from "./00-query";
2
+ export declare class BySiblingQuery implements Query {
3
+ readonly subQuery: Query;
4
+ readonly shouldBeFound: boolean;
5
+ readonly siblingTags: string[];
6
+ constructor(subQuery: Query, shouldBeFound: boolean, siblingTags: string[]);
7
+ execute(): QueryResult[];
8
+ private computeResult;
9
+ private foundSiblingElement;
10
+ getSelector(): string;
11
+ private addGhostInputNode;
12
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BySiblingQuery = void 0;
7
+ const _00_query_1 = require("./00-query");
8
+ const lodash_1 = __importDefault(require("lodash"));
9
+ const emulate_tab_1 = require("emulate-tab");
10
+ const DATA_TESTID = "data-testid";
11
+ const BODY = "BODY";
12
+ class BySiblingQuery {
13
+ subQuery;
14
+ shouldBeFound;
15
+ siblingTags;
16
+ constructor(subQuery, shouldBeFound, siblingTags) {
17
+ this.subQuery = subQuery;
18
+ this.shouldBeFound = shouldBeFound;
19
+ this.siblingTags = siblingTags;
20
+ }
21
+ execute() {
22
+ const result = [];
23
+ this.subQuery.execute().forEach((currentElement) => {
24
+ const element = currentElement.domNode;
25
+ element.focus();
26
+ if (document.activeElement?.tagName === BODY) {
27
+ const ghost = this.addGhostInputNode(element);
28
+ ghost.focus();
29
+ this.computeResult(element, result, ghost);
30
+ ghost.remove();
31
+ }
32
+ else {
33
+ this.computeResult(element, result);
34
+ }
35
+ });
36
+ return result;
37
+ }
38
+ computeResult(element, result, ghost = undefined) {
39
+ const elementFocused = ghost ?? element;
40
+ const siblingElements = [];
41
+ emulate_tab_1.emulateTab.findSelectableElements().forEach((value, index, collection) => {
42
+ if (value.getAttribute(DATA_TESTID) === elementFocused.getAttribute(DATA_TESTID)) {
43
+ const previousExist = index - 1 >= 0;
44
+ const nextExist = index + 1 <= collection.length - 1;
45
+ if (this.shouldBeFound) {
46
+ if (previousExist && this.foundSiblingElement(collection[index - 1])) {
47
+ siblingElements.push(collection[index - 1]);
48
+ }
49
+ if (nextExist && this.foundSiblingElement(collection[index + 1])) {
50
+ siblingElements.push(collection[index + 1]);
51
+ }
52
+ if (!lodash_1.default.isEmpty(siblingElements)) {
53
+ result.push(new _00_query_1.QueryResult(element, siblingElements));
54
+ }
55
+ }
56
+ else {
57
+ if ((previousExist &&
58
+ !this.foundSiblingElement(collection[index - 1]) &&
59
+ nextExist &&
60
+ !this.foundSiblingElement(collection[index + 1]))) {
61
+ siblingElements.push(collection[index - 1]);
62
+ siblingElements.push(collection[index + 1]);
63
+ }
64
+ if ((previousExist &&
65
+ !this.foundSiblingElement(collection[index - 1]) &&
66
+ !nextExist)) {
67
+ siblingElements.push(collection[index - 1]);
68
+ result.push(new _00_query_1.QueryResult(element, siblingElements));
69
+ }
70
+ if ((!previousExist &&
71
+ nextExist &&
72
+ !this.foundSiblingElement(collection[index + 1]))) {
73
+ siblingElements.push(collection[index + 1]);
74
+ }
75
+ if (!lodash_1.default.isEmpty(siblingElements)) {
76
+ result.push(new _00_query_1.QueryResult(element, siblingElements));
77
+ }
78
+ }
79
+ }
80
+ });
81
+ }
82
+ foundSiblingElement(element) {
83
+ return this.siblingTags.includes(element.tagName.toLowerCase());
84
+ }
85
+ getSelector() {
86
+ return `${this.subQuery.getSelector()}`;
87
+ }
88
+ addGhostInputNode(element) {
89
+ const input = document.createElement("input");
90
+ input.setAttribute(DATA_TESTID, "to-delete-" + String(Math.floor(Math.random() * Date.now())));
91
+ if (element.parentNode) {
92
+ element.parentNode.insertBefore(input, element.nextSibling);
93
+ }
94
+ else {
95
+ element.insertBefore(input, element.nextSibling);
96
+ }
97
+ return input;
98
+ }
99
+ }
100
+ exports.BySiblingQuery = BySiblingQuery;
@@ -1,7 +1,7 @@
1
- import { Query } from "./00-query";
1
+ import { Query, QueryResult } from "./00-query";
2
2
  export declare class ByTagQuery implements Query {
3
3
  readonly selectors: string[];
4
4
  constructor(selectors: string[]);
5
- execute(): HTMLElement[];
5
+ execute(): QueryResult[];
6
6
  getSelector(): string;
7
7
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ByTagQuery = void 0;
4
+ const _00_query_1 = require("./00-query");
4
5
  // eslint-disable-next-line @typescript-eslint/no-var-requires
5
6
  const $ = require("jquery/dist/jquery.min");
6
7
  class ByTagQuery {
@@ -9,7 +10,7 @@ class ByTagQuery {
9
10
  this.selectors = selectors;
10
11
  }
11
12
  execute() {
12
- return $(this.selectors.join(",")).toArray();
13
+ return $(this.selectors.join(",")).toArray().map((element) => new _00_query_1.QueryResult(element));
13
14
  }
14
15
  getSelector() {
15
16
  return `${this.selectors}`;
@@ -0,0 +1,34 @@
1
+ export interface IAttributeSpecification {
2
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
3
+ }
4
+ export declare class EmptyAttributeSpecification implements IAttributeSpecification {
5
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
6
+ }
7
+ export declare class NotEmptyAttributeSpecification implements IAttributeSpecification {
8
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
9
+ }
10
+ export declare class EmptyElementWithIdSpecification implements IAttributeSpecification {
11
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
12
+ }
13
+ export declare class NotUniqueIdAttributeSpecification implements IAttributeSpecification {
14
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
15
+ }
16
+ export declare class NotEqualsAttributeSpecification implements IAttributeSpecification {
17
+ private expectedValueList;
18
+ constructor(expectedValueList: string[]);
19
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
20
+ }
21
+ export declare class EqualsAttributeSpecification implements IAttributeSpecification {
22
+ private expectedValueList;
23
+ constructor(expectedValueList: string[]);
24
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
25
+ }
26
+ export declare class AccessibleNameNotContainsVisibleTextSpecification implements IAttributeSpecification {
27
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
28
+ }
29
+ export declare class EmptyInnerTextSpecification implements IAttributeSpecification {
30
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
31
+ }
32
+ export declare class NotEmptyInnerTextSpecification implements IAttributeSpecification {
33
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
34
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NotEmptyInnerTextSpecification = exports.EmptyInnerTextSpecification = exports.AccessibleNameNotContainsVisibleTextSpecification = exports.EqualsAttributeSpecification = exports.NotEqualsAttributeSpecification = exports.NotUniqueIdAttributeSpecification = exports.EmptyElementWithIdSpecification = exports.NotEmptyAttributeSpecification = exports.EmptyAttributeSpecification = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
9
+ const $ = require("jquery/dist/jquery.min");
10
+ const dom_accessibility_api_1 = require("dom-accessibility-api");
11
+ class EmptyAttributeSpecification {
12
+ isSatisfiedBy(element, attributeName) {
13
+ const attributeValue = element.getAttribute(attributeName);
14
+ return lodash_1.default.isEmpty(attributeValue);
15
+ }
16
+ }
17
+ exports.EmptyAttributeSpecification = EmptyAttributeSpecification;
18
+ class NotEmptyAttributeSpecification {
19
+ isSatisfiedBy(element, attributeName) {
20
+ const attributeValue = element.getAttribute(attributeName);
21
+ return !lodash_1.default.isEmpty(attributeValue);
22
+ }
23
+ }
24
+ exports.NotEmptyAttributeSpecification = NotEmptyAttributeSpecification;
25
+ class EmptyElementWithIdSpecification {
26
+ isSatisfiedBy(element, attributeName) {
27
+ const attributeValue = element.getAttribute(attributeName);
28
+ if (attributeValue === null || lodash_1.default.isEmpty(attributeValue)) {
29
+ return true;
30
+ }
31
+ const bindingNodeId = $(`#${attributeValue.replaceAll(".", "\\.")}`).text();
32
+ return lodash_1.default.isEmpty(bindingNodeId);
33
+ }
34
+ }
35
+ exports.EmptyElementWithIdSpecification = EmptyElementWithIdSpecification;
36
+ class NotUniqueIdAttributeSpecification {
37
+ isSatisfiedBy(element, attributeName) {
38
+ if (lodash_1.default.isNull(element.id) || lodash_1.default.isEmpty(element.id)) {
39
+ return true;
40
+ }
41
+ return $(`[id=${element.id}]`).length > 1;
42
+ }
43
+ }
44
+ exports.NotUniqueIdAttributeSpecification = NotUniqueIdAttributeSpecification;
45
+ class NotEqualsAttributeSpecification {
46
+ expectedValueList;
47
+ constructor(expectedValueList) {
48
+ this.expectedValueList = expectedValueList;
49
+ }
50
+ isSatisfiedBy(element, attributeName) {
51
+ const attributeValue = element.getAttribute(attributeName);
52
+ if (attributeValue === null) {
53
+ return true;
54
+ }
55
+ return !this.expectedValueList.includes(attributeValue);
56
+ }
57
+ }
58
+ exports.NotEqualsAttributeSpecification = NotEqualsAttributeSpecification;
59
+ class EqualsAttributeSpecification {
60
+ expectedValueList;
61
+ constructor(expectedValueList) {
62
+ this.expectedValueList = expectedValueList;
63
+ }
64
+ isSatisfiedBy(element, attributeName) {
65
+ const attributeValue = element.getAttribute(attributeName);
66
+ if (attributeValue === null) {
67
+ return false;
68
+ }
69
+ return this.expectedValueList.includes(attributeValue);
70
+ }
71
+ }
72
+ exports.EqualsAttributeSpecification = EqualsAttributeSpecification;
73
+ class AccessibleNameNotContainsVisibleTextSpecification {
74
+ isSatisfiedBy(element, attributeName) {
75
+ const visibleText = element.textContent;
76
+ if (visibleText === null || lodash_1.default.isEmpty(visibleText)) {
77
+ return false;
78
+ }
79
+ const accessibleName = (0, dom_accessibility_api_1.computeAccessibleName)(element);
80
+ console.debug("visibleText", visibleText, "accessibleName", accessibleName);
81
+ return accessibleName?.toLowerCase().indexOf(visibleText.toLowerCase()) === -1;
82
+ }
83
+ }
84
+ exports.AccessibleNameNotContainsVisibleTextSpecification = AccessibleNameNotContainsVisibleTextSpecification;
85
+ class EmptyInnerTextSpecification {
86
+ isSatisfiedBy(element, attributeName) {
87
+ return lodash_1.default.isEmpty(element.textContent);
88
+ }
89
+ }
90
+ exports.EmptyInnerTextSpecification = EmptyInnerTextSpecification;
91
+ class NotEmptyInnerTextSpecification {
92
+ isSatisfiedBy(element, attributeName) {
93
+ return !lodash_1.default.isEmpty(element.textContent);
94
+ }
95
+ }
96
+ exports.NotEmptyInnerTextSpecification = NotEmptyInnerTextSpecification;