@siteimprove/alfa-dom 0.89.2

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 (140) hide show
  1. package/CHANGELOG.md +291 -0
  2. package/dist/h.d.ts +37 -0
  3. package/dist/h.js +214 -0
  4. package/dist/index.d.ts +32 -0
  5. package/dist/index.js +32 -0
  6. package/dist/jsx-runtime.d.ts +26 -0
  7. package/dist/jsx-runtime.js +41 -0
  8. package/dist/jsx.d.ts +44 -0
  9. package/dist/jsx.js +45 -0
  10. package/dist/namespace.d.ts +43 -0
  11. package/dist/namespace.js +57 -0
  12. package/dist/native.d.ts +18 -0
  13. package/dist/native.js +449 -0
  14. package/dist/node/attribute/predicate/has-name.d.ts +11 -0
  15. package/dist/node/attribute/predicate/has-name.js +13 -0
  16. package/dist/node/attribute/predicate.d.ts +2 -0
  17. package/dist/node/attribute/predicate.js +2 -0
  18. package/dist/node/attribute.d.ts +90 -0
  19. package/dist/node/attribute.js +164 -0
  20. package/dist/node/comment.d.ts +42 -0
  21. package/dist/node/comment.js +74 -0
  22. package/dist/node/document.d.ts +59 -0
  23. package/dist/node/document.js +113 -0
  24. package/dist/node/element/input-type.d.ts +12 -0
  25. package/dist/node/element/input-type.js +10 -0
  26. package/dist/node/element/predicate/has-attribute.d.ts +12 -0
  27. package/dist/node/element/predicate/has-attribute.js +11 -0
  28. package/dist/node/element/predicate/has-box.d.ts +9 -0
  29. package/dist/node/element/predicate/has-box.js +7 -0
  30. package/dist/node/element/predicate/has-display-size.d.ts +7 -0
  31. package/dist/node/element/predicate/has-display-size.js +28 -0
  32. package/dist/node/element/predicate/has-id.d.ts +16 -0
  33. package/dist/node/element/predicate/has-id.js +17 -0
  34. package/dist/node/element/predicate/has-input-type.d.ts +12 -0
  35. package/dist/node/element/predicate/has-input-type.js +17 -0
  36. package/dist/node/element/predicate/has-name.d.ts +11 -0
  37. package/dist/node/element/predicate/has-name.js +13 -0
  38. package/dist/node/element/predicate/has-namespace.d.ts +12 -0
  39. package/dist/node/element/predicate/has-namespace.js +13 -0
  40. package/dist/node/element/predicate/has-tab-index.d.ts +12 -0
  41. package/dist/node/element/predicate/has-tab-index.js +11 -0
  42. package/dist/node/element/predicate/has-unique-id.d.ts +7 -0
  43. package/dist/node/element/predicate/has-unique-id.js +31 -0
  44. package/dist/node/element/predicate/is-actually-disabled.d.ts +8 -0
  45. package/dist/node/element/predicate/is-actually-disabled.js +47 -0
  46. package/dist/node/element/predicate/is-browsing-context-container.d.ts +8 -0
  47. package/dist/node/element/predicate/is-browsing-context-container.js +20 -0
  48. package/dist/node/element/predicate/is-content.d.ts +10 -0
  49. package/dist/node/element/predicate/is-content.js +17 -0
  50. package/dist/node/element/predicate/is-document-element.d.ts +6 -0
  51. package/dist/node/element/predicate/is-document-element.js +13 -0
  52. package/dist/node/element/predicate/is-draggable.d.ts +8 -0
  53. package/dist/node/element/predicate/is-draggable.js +28 -0
  54. package/dist/node/element/predicate/is-editing-host.d.ts +8 -0
  55. package/dist/node/element/predicate/is-editing-host.js +20 -0
  56. package/dist/node/element/predicate/is-fallback.d.ts +15 -0
  57. package/dist/node/element/predicate/is-fallback.js +28 -0
  58. package/dist/node/element/predicate/is-replaced.d.ts +8 -0
  59. package/dist/node/element/predicate/is-replaced.js +17 -0
  60. package/dist/node/element/predicate/is-scoped-to.d.ts +7 -0
  61. package/dist/node/element/predicate/is-scoped-to.js +11 -0
  62. package/dist/node/element/predicate/is-suggested-focusable.d.ts +14 -0
  63. package/dist/node/element/predicate/is-suggested-focusable.js +47 -0
  64. package/dist/node/element/predicate.d.ts +20 -0
  65. package/dist/node/element/predicate.js +20 -0
  66. package/dist/node/element.d.ts +122 -0
  67. package/dist/node/element.js +330 -0
  68. package/dist/node/fragment.d.ts +38 -0
  69. package/dist/node/fragment.js +68 -0
  70. package/dist/node/predicate/has-child.d.ts +7 -0
  71. package/dist/node/predicate/has-child.js +8 -0
  72. package/dist/node/predicate/has-descendant.d.ts +7 -0
  73. package/dist/node/predicate/has-descendant.js +8 -0
  74. package/dist/node/predicate/has-inclusive-descendant.d.ts +7 -0
  75. package/dist/node/predicate/has-inclusive-descendant.js +8 -0
  76. package/dist/node/predicate/has-text-content.d.ts +7 -0
  77. package/dist/node/predicate/has-text-content.js +12 -0
  78. package/dist/node/predicate/is-root.d.ts +7 -0
  79. package/dist/node/predicate/is-root.js +7 -0
  80. package/dist/node/predicate.d.ts +6 -0
  81. package/dist/node/predicate.js +6 -0
  82. package/dist/node/query/element-descendants.d.ts +8 -0
  83. package/dist/node/query/element-descendants.js +17 -0
  84. package/dist/node/query/element-id-map.d.ts +14 -0
  85. package/dist/node/query/element-id-map.js +30 -0
  86. package/dist/node/query/inclusive-element-descendants.d.ts +8 -0
  87. package/dist/node/query/inclusive-element-descendants.js +10 -0
  88. package/dist/node/query/index.d.ts +12 -0
  89. package/dist/node/query/index.js +13 -0
  90. package/dist/node/shadow.d.ts +66 -0
  91. package/dist/node/shadow.js +128 -0
  92. package/dist/node/slot.d.ts +29 -0
  93. package/dist/node/slot.js +41 -0
  94. package/dist/node/slotable.d.ts +29 -0
  95. package/dist/node/slotable.js +40 -0
  96. package/dist/node/text.d.ts +46 -0
  97. package/dist/node/text.js +83 -0
  98. package/dist/node/traversal/get-nodes-between.d.ts +24 -0
  99. package/dist/node/traversal/get-nodes-between.js +62 -0
  100. package/dist/node/traversal/lowest-common-ancestor.d.ts +13 -0
  101. package/dist/node/traversal/lowest-common-ancestor.js +19 -0
  102. package/dist/node/traversal.d.ts +2 -0
  103. package/dist/node/traversal.js +2 -0
  104. package/dist/node/type.d.ts +45 -0
  105. package/dist/node/type.js +74 -0
  106. package/dist/node.d.ts +263 -0
  107. package/dist/node.js +325 -0
  108. package/dist/style/block.d.ts +30 -0
  109. package/dist/style/block.js +63 -0
  110. package/dist/style/declaration.d.ts +65 -0
  111. package/dist/style/declaration.js +103 -0
  112. package/dist/style/rule/condition.d.ts +21 -0
  113. package/dist/style/rule/condition.js +30 -0
  114. package/dist/style/rule/font-face.d.ts +29 -0
  115. package/dist/style/rule/font-face.js +47 -0
  116. package/dist/style/rule/grouping.d.ts +22 -0
  117. package/dist/style/rule/grouping.js +34 -0
  118. package/dist/style/rule/import.d.ts +47 -0
  119. package/dist/style/rule/import.js +114 -0
  120. package/dist/style/rule/keyframe.d.ts +32 -0
  121. package/dist/style/rule/keyframe.js +53 -0
  122. package/dist/style/rule/keyframes.d.ts +28 -0
  123. package/dist/style/rule/keyframes.js +49 -0
  124. package/dist/style/rule/layer.d.ts +61 -0
  125. package/dist/style/rule/layer.js +106 -0
  126. package/dist/style/rule/media.d.ts +32 -0
  127. package/dist/style/rule/media.js +54 -0
  128. package/dist/style/rule/namespace.d.ts +31 -0
  129. package/dist/style/rule/namespace.js +52 -0
  130. package/dist/style/rule/page.d.ts +32 -0
  131. package/dist/style/rule/page.js +53 -0
  132. package/dist/style/rule/style.d.ts +35 -0
  133. package/dist/style/rule/style.js +62 -0
  134. package/dist/style/rule/supports.d.ts +32 -0
  135. package/dist/style/rule/supports.js +56 -0
  136. package/dist/style/rule.d.ts +60 -0
  137. package/dist/style/rule.js +109 -0
  138. package/dist/style/sheet.d.ts +37 -0
  139. package/dist/style/sheet.js +66 -0
  140. package/package.json +69 -0
@@ -0,0 +1,2 @@
1
+ export * from "./predicate/has-name.js";
2
+ //# sourceMappingURL=predicate.js.map
@@ -0,0 +1,90 @@
1
+ import { Option } from "@siteimprove/alfa-option";
2
+ import { Sequence } from "@siteimprove/alfa-sequence";
3
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
4
+ import * as json from "@siteimprove/alfa-json";
5
+ import { Namespace } from "../namespace.js";
6
+ import { Node } from "../node.js";
7
+ import type { Element } from "./element.js";
8
+ import * as predicate from "./attribute/predicate.js";
9
+ /**
10
+ * @public
11
+ */
12
+ export declare class Attribute<N extends string = string> extends Node<"attribute"> {
13
+ static of<N extends string = string>(namespace: Option<Namespace>, prefix: Option<string>, name: N, value: string, externalId?: string, serializationId?: string, extraData?: any): Attribute<N>;
14
+ private readonly _namespace;
15
+ private readonly _prefix;
16
+ private readonly _name;
17
+ private readonly _value;
18
+ private _owner;
19
+ private constructor();
20
+ get namespace(): Option<Namespace>;
21
+ get prefix(): Option<string>;
22
+ get name(): N | Lowercase<N>;
23
+ get qualifiedName(): string;
24
+ get value(): string;
25
+ get owner(): Option<Element>;
26
+ /**
27
+ * {@link https://html.spec.whatwg.org/#boolean-attribute}
28
+ */
29
+ isBoolean(): boolean;
30
+ /**
31
+ * @internal
32
+ **/
33
+ protected _internalPath(options?: Node.Traversal): string;
34
+ /**
35
+ * {@link https://html.spec.whatwg.org/#space-separated-tokens}
36
+ */
37
+ tokens(separator?: string | RegExp): Sequence<string>;
38
+ /**
39
+ * {@link https://html.spec.whatwg.org/#enumerated-attribute}
40
+ */
41
+ enumerate(): Option<string>;
42
+ /**
43
+ * {@link https://html.spec.whatwg.org/#enumerated-attribute}
44
+ */
45
+ enumerate<T extends string>(valid: T, ...rest: Array<T>): Option<T>;
46
+ toJSON(options: Node.SerializationOptions & {
47
+ verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
48
+ }): Attribute.MinimalJSON;
49
+ toJSON(options?: Node.SerializationOptions): Attribute.JSON<N>;
50
+ toString(): string;
51
+ /**
52
+ * @internal
53
+ */
54
+ _attachParent(): boolean;
55
+ /**
56
+ * @internal
57
+ */
58
+ _attachOwner(owner: Element): boolean;
59
+ }
60
+ /**
61
+ * @public
62
+ */
63
+ export declare namespace Attribute {
64
+ interface MinimalJSON extends Node.JSON<"attribute"> {
65
+ }
66
+ interface JSON<N extends string = string> extends Node.JSON<"attribute"> {
67
+ namespace: string | null;
68
+ prefix: string | null;
69
+ name: N;
70
+ value: string;
71
+ }
72
+ function isAttribute(value: unknown): value is Attribute;
73
+ /**
74
+ * @internal
75
+ */
76
+ function fromAttribute<N extends string = string>(attribute: JSON<N>): Trampoline<Attribute<N>>;
77
+ /**
78
+ * @internal
79
+ */
80
+ function cloneAttribute<N extends string = string>(attribute: Attribute<N>): Trampoline<Attribute<N | Lowercase<N>>>;
81
+ /**
82
+ * Conditionally fold the case of an attribute name based on its owner; HTML
83
+ * attributes are case insensitive while attributes in other namespaces aren't.
84
+ *
85
+ * @internal
86
+ */
87
+ function foldCase<N extends string = string>(name: N, owner: Option<Element>): N | Lowercase<N>;
88
+ const hasName: typeof predicate.hasName;
89
+ }
90
+ //# sourceMappingURL=attribute.d.ts.map
@@ -0,0 +1,164 @@
1
+ import { Iterable } from "@siteimprove/alfa-iterable";
2
+ import { None, Option } from "@siteimprove/alfa-option";
3
+ import { Predicate } from "@siteimprove/alfa-predicate";
4
+ import { Sequence } from "@siteimprove/alfa-sequence";
5
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
6
+ import * as json from "@siteimprove/alfa-json";
7
+ import { Namespace } from "../namespace.js";
8
+ import { Node } from "../node.js";
9
+ import * as predicate from "./attribute/predicate.js";
10
+ const { isEmpty } = Iterable;
11
+ const { equals, not } = Predicate;
12
+ /**
13
+ * @public
14
+ */
15
+ export class Attribute extends Node {
16
+ static of(namespace, prefix, name, value, externalId, serializationId, extraData) {
17
+ return new Attribute(namespace, prefix, name, value, externalId, serializationId, extraData);
18
+ }
19
+ _namespace;
20
+ _prefix;
21
+ _name;
22
+ _value;
23
+ _owner = None;
24
+ constructor(namespace, prefix, name, value, externalId, serializationId, extraData) {
25
+ super([], "attribute", externalId, serializationId, extraData);
26
+ this._namespace = namespace;
27
+ this._prefix = prefix;
28
+ this._name = name;
29
+ this._value = value;
30
+ }
31
+ get namespace() {
32
+ return this._namespace;
33
+ }
34
+ get prefix() {
35
+ return this._prefix;
36
+ }
37
+ get name() {
38
+ return Attribute.foldCase(this._name, this._owner);
39
+ }
40
+ get qualifiedName() {
41
+ return this._prefix.reduce((name, prefix) => `${prefix}:${name}`, this._name);
42
+ }
43
+ get value() {
44
+ return this._value;
45
+ }
46
+ get owner() {
47
+ return this._owner;
48
+ }
49
+ /**
50
+ * {@link https://html.spec.whatwg.org/#boolean-attribute}
51
+ */
52
+ isBoolean() {
53
+ switch (this.name) {
54
+ case "allowfullscreen":
55
+ case "allowpaymentrequest":
56
+ case "async":
57
+ case "autofocus":
58
+ case "autoplay":
59
+ case "checked":
60
+ case "controls":
61
+ case "default":
62
+ return true;
63
+ default:
64
+ return false;
65
+ }
66
+ }
67
+ /**
68
+ * @internal
69
+ **/
70
+ _internalPath(options) {
71
+ let path = this.owner.map((owner) => owner.path(options)).getOr("/");
72
+ path += path === "/" ? "" : "/";
73
+ path += `@${this.name}`;
74
+ return path;
75
+ }
76
+ /**
77
+ * {@link https://html.spec.whatwg.org/#space-separated-tokens}
78
+ */
79
+ tokens(separator = /\s+/) {
80
+ return Sequence.from(this._value.trim().split(separator).filter(not(isEmpty)));
81
+ }
82
+ enumerate(...valid) {
83
+ const value = this._value.toLowerCase();
84
+ return valid.length === 0 || valid.includes(value)
85
+ ? Option.of(value)
86
+ : None;
87
+ }
88
+ toJSON(options) {
89
+ const result = {
90
+ ...super.toJSON(options),
91
+ };
92
+ delete result.children;
93
+ const verbosity = options?.verbosity ?? json.Serializable.Verbosity.Medium;
94
+ if (verbosity < json.Serializable.Verbosity.Medium) {
95
+ return result;
96
+ }
97
+ result.namespace = this._namespace.getOr(null);
98
+ result.prefix = this._prefix.getOr(null);
99
+ result.name = this._name;
100
+ result.value = this._value;
101
+ return result;
102
+ }
103
+ toString() {
104
+ const name = this.qualifiedName;
105
+ if (this.isBoolean()) {
106
+ return name;
107
+ }
108
+ return `${name}="${this._value.replace(/"/g, "&quot;")}"`;
109
+ }
110
+ /**
111
+ * @internal
112
+ */
113
+ _attachParent() {
114
+ return false;
115
+ }
116
+ /**
117
+ * @internal
118
+ */
119
+ _attachOwner(owner) {
120
+ if (this._frozen || this._owner.isSome()) {
121
+ return false;
122
+ }
123
+ this._owner = Option.of(owner);
124
+ this._frozen = true;
125
+ return true;
126
+ }
127
+ }
128
+ /**
129
+ * @public
130
+ */
131
+ (function (Attribute) {
132
+ function isAttribute(value) {
133
+ return value instanceof Attribute;
134
+ }
135
+ Attribute.isAttribute = isAttribute;
136
+ /**
137
+ * @internal
138
+ */
139
+ function fromAttribute(attribute) {
140
+ return Trampoline.done(Attribute.of(Option.from(attribute.namespace), Option.from(attribute.prefix), attribute.name, attribute.value, attribute.externalId, attribute.serializationId));
141
+ }
142
+ Attribute.fromAttribute = fromAttribute;
143
+ /**
144
+ * @internal
145
+ */
146
+ function cloneAttribute(attribute) {
147
+ return Trampoline.done(Attribute.of(attribute.namespace, attribute.prefix, attribute.name, attribute.value, attribute.externalId, attribute.serializationId, attribute.extraData));
148
+ }
149
+ Attribute.cloneAttribute = cloneAttribute;
150
+ /**
151
+ * Conditionally fold the case of an attribute name based on its owner; HTML
152
+ * attributes are case insensitive while attributes in other namespaces aren't.
153
+ *
154
+ * @internal
155
+ */
156
+ function foldCase(name, owner) {
157
+ return owner.some((owner) => owner.namespace.some(equals(Namespace.HTML)))
158
+ ? name.toLowerCase()
159
+ : name;
160
+ }
161
+ Attribute.foldCase = foldCase;
162
+ Attribute.hasName = predicate.hasName;
163
+ })(Attribute || (Attribute = {}));
164
+ //# sourceMappingURL=attribute.js.map
@@ -0,0 +1,42 @@
1
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
2
+ import * as json from "@siteimprove/alfa-json";
3
+ import { Node } from "../node.js";
4
+ /**
5
+ * @public
6
+ */
7
+ export declare class Comment extends Node<"comment"> {
8
+ static of(data: string, externalId?: string, serializationId?: string, extraData?: any): Comment;
9
+ static empty(): Comment;
10
+ private readonly _data;
11
+ private constructor();
12
+ get data(): string;
13
+ /**
14
+ * @internal
15
+ **/
16
+ protected _internalPath(options?: Node.Traversal): string;
17
+ toJSON(options: Node.SerializationOptions & {
18
+ verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
19
+ }): Comment.MinimalJSON;
20
+ toJSON(options?: Node.SerializationOptions): Comment.JSON;
21
+ toString(): string;
22
+ }
23
+ /**
24
+ * @public
25
+ */
26
+ export declare namespace Comment {
27
+ interface MinimalJSON extends Node.JSON<"comment"> {
28
+ }
29
+ interface JSON extends Node.JSON<"comment"> {
30
+ data: string;
31
+ }
32
+ function isComment(value: unknown): value is Comment;
33
+ /**
34
+ * @internal
35
+ */
36
+ function fromComment(json: JSON): Trampoline<Comment>;
37
+ /**
38
+ * @internal
39
+ */
40
+ function cloneComment(comment: Comment): Trampoline<Comment>;
41
+ }
42
+ //# sourceMappingURL=comment.d.ts.map
@@ -0,0 +1,74 @@
1
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
2
+ import * as json from "@siteimprove/alfa-json";
3
+ import { Node } from "../node.js";
4
+ /**
5
+ * @public
6
+ */
7
+ export class Comment extends Node {
8
+ static of(data, externalId, serializationId, extraData) {
9
+ return new Comment(data, externalId, serializationId, extraData);
10
+ }
11
+ static empty() {
12
+ return new Comment("");
13
+ }
14
+ _data;
15
+ constructor(data, externalId, serializationId, extraData) {
16
+ super([], "comment", externalId, serializationId, extraData);
17
+ this._data = data;
18
+ }
19
+ get data() {
20
+ return this._data;
21
+ }
22
+ /**
23
+ * @internal
24
+ **/
25
+ _internalPath(options) {
26
+ let path = this.parent(options)
27
+ .map((parent) => parent.path(options))
28
+ .getOr("/");
29
+ path += path === "/" ? "" : "/";
30
+ path += "comment()";
31
+ const index = this.preceding(options).count(Comment.isComment);
32
+ path += `[${index + 1}]`;
33
+ return path;
34
+ }
35
+ toJSON(options) {
36
+ const result = {
37
+ ...super.toJSON(options),
38
+ };
39
+ delete result.children;
40
+ const verbosity = options?.verbosity ?? json.Serializable.Verbosity.Medium;
41
+ if (verbosity < json.Serializable.Verbosity.Medium) {
42
+ return result;
43
+ }
44
+ result.data = this._data;
45
+ return result;
46
+ }
47
+ toString() {
48
+ return `<!--${this._data}-->`;
49
+ }
50
+ }
51
+ /**
52
+ * @public
53
+ */
54
+ (function (Comment) {
55
+ function isComment(value) {
56
+ return value instanceof Comment;
57
+ }
58
+ Comment.isComment = isComment;
59
+ /**
60
+ * @internal
61
+ */
62
+ function fromComment(json) {
63
+ return Trampoline.done(Comment.of(json.data, json.externalId, json.serializationId));
64
+ }
65
+ Comment.fromComment = fromComment;
66
+ /**
67
+ * @internal
68
+ */
69
+ function cloneComment(comment) {
70
+ return Trampoline.done(Comment.of(comment.data, comment.externalId, comment.serializationId, comment.extraData));
71
+ }
72
+ Comment.cloneComment = cloneComment;
73
+ })(Comment || (Comment = {}));
74
+ //# sourceMappingURL=comment.js.map
@@ -0,0 +1,59 @@
1
+ import { Array } from "@siteimprove/alfa-array";
2
+ import type { Device } from "@siteimprove/alfa-device";
3
+ import { Iterable } from "@siteimprove/alfa-iterable";
4
+ import { Option } from "@siteimprove/alfa-option";
5
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
6
+ import * as json from "@siteimprove/alfa-json";
7
+ import { Node } from "../node.js";
8
+ import { Sheet } from "../style/sheet.js";
9
+ import { Element } from "./element.js";
10
+ /**
11
+ * @public
12
+ */
13
+ export declare class Document extends Node<"document"> {
14
+ static of(children: Iterable<Node>, style?: Iterable<Sheet>, externalId?: string, serializationId?: string, extraData?: any): Document;
15
+ static empty(): Document;
16
+ private readonly _style;
17
+ private _frame;
18
+ private constructor();
19
+ get style(): Iterable<Sheet>;
20
+ get frame(): Option<Element>;
21
+ parent(options?: Node.Traversal): Option<Node>;
22
+ /**
23
+ * @internal
24
+ **/
25
+ protected _internalPath(options?: Node.Traversal): string;
26
+ toJSON(options: Node.SerializationOptions & {
27
+ verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
28
+ }): Document.MinimalJSON;
29
+ toJSON(options?: Node.SerializationOptions): Document.JSON;
30
+ toString(): string;
31
+ /**
32
+ * @internal
33
+ */
34
+ _attachParent(): boolean;
35
+ /**
36
+ * @internal
37
+ */
38
+ _attachFrame(frame: Element): boolean;
39
+ }
40
+ /**
41
+ * @public
42
+ */
43
+ export declare namespace Document {
44
+ interface MinimalJSON extends Node.JSON<"document"> {
45
+ }
46
+ interface JSON extends Node.JSON<"document"> {
47
+ style: Array<Sheet.JSON>;
48
+ }
49
+ function isDocument(value: unknown): value is Document;
50
+ /**
51
+ * @internal
52
+ */
53
+ function fromDocument(json: JSON, device?: Device): Trampoline<Document>;
54
+ /**
55
+ * @internal
56
+ */
57
+ function cloneDocument(options: Node.ElementReplacementOptions, device?: Device): (document: Document) => Trampoline<Document>;
58
+ }
59
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1,113 @@
1
+ import { Array } from "@siteimprove/alfa-array";
2
+ import { Iterable } from "@siteimprove/alfa-iterable";
3
+ import { None, Option } from "@siteimprove/alfa-option";
4
+ import { String } from "@siteimprove/alfa-string";
5
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
6
+ import * as json from "@siteimprove/alfa-json";
7
+ import { Node } from "../node.js";
8
+ import { Sheet } from "../style/sheet.js";
9
+ import { Element } from "./element.js";
10
+ /**
11
+ * @public
12
+ */
13
+ export class Document extends Node {
14
+ static of(children, style = [], externalId, serializationId, extraData) {
15
+ return new Document(Array.from(children), style, externalId, serializationId, extraData);
16
+ }
17
+ static empty() {
18
+ return new Document([], []);
19
+ }
20
+ _style;
21
+ _frame = None;
22
+ constructor(children, style, externalId, serializationId, extraData) {
23
+ super(children, "document", externalId, serializationId, extraData);
24
+ this._style = Array.from(style);
25
+ }
26
+ get style() {
27
+ return this._style;
28
+ }
29
+ get frame() {
30
+ return this._frame;
31
+ }
32
+ parent(options = Node.Traversal.empty) {
33
+ return options.isSet(Node.Traversal.nested)
34
+ ? this.frame
35
+ : super.parent(options);
36
+ }
37
+ /**
38
+ * @internal
39
+ **/
40
+ _internalPath(options = Node.Traversal.empty) {
41
+ if (options.isSet(Node.Traversal.nested)) {
42
+ return this._frame
43
+ .map((frame) => frame.path(options) + "/document-node()")
44
+ .getOr("/");
45
+ }
46
+ return "/";
47
+ }
48
+ toJSON(options) {
49
+ const result = {
50
+ ...super.toJSON(options),
51
+ };
52
+ const verbosity = options?.verbosity ?? json.Serializable.Verbosity.Medium;
53
+ if (verbosity < json.Serializable.Verbosity.Medium) {
54
+ return result;
55
+ }
56
+ result.style = this._style.map((sheet) => sheet.toJSON());
57
+ return result;
58
+ }
59
+ toString() {
60
+ const children = this._children
61
+ .map((child) => String.indent(child.toString()))
62
+ .join("\n");
63
+ return `#document${children === "" ? "" : `\n${children}`}`;
64
+ }
65
+ /**
66
+ * @internal
67
+ */
68
+ _attachParent() {
69
+ return false;
70
+ }
71
+ /**
72
+ * @internal
73
+ */
74
+ _attachFrame(frame) {
75
+ if (this._frozen || this._frame.isSome()) {
76
+ return false;
77
+ }
78
+ this._frame = Option.of(frame);
79
+ this._frozen = true;
80
+ return true;
81
+ }
82
+ }
83
+ /**
84
+ * @public
85
+ */
86
+ (function (Document) {
87
+ function isDocument(value) {
88
+ return value instanceof Document;
89
+ }
90
+ Document.isDocument = isDocument;
91
+ /**
92
+ * @internal
93
+ */
94
+ function fromDocument(json, device) {
95
+ return Trampoline.traverse(json.children ?? [], (child) => Node.fromNode(child, device)).map((children) => Document.of(children, json.style.map(Sheet.from), json.externalId, json.serializationId));
96
+ }
97
+ Document.fromDocument = fromDocument;
98
+ /**
99
+ * @internal
100
+ */
101
+ function cloneDocument(options, device) {
102
+ return (document) => Trampoline.traverse(document.children(), (child) => {
103
+ if (Element.isElement(child) && options.predicate(child)) {
104
+ return Trampoline.done(Array.from(options.newElements));
105
+ }
106
+ return Node.cloneNode(child, options, device).map((node) => [node]);
107
+ }).map((children) => {
108
+ return Document.of(Iterable.flatten(children), document.style, document.externalId, document.serializationId, document.extraData);
109
+ });
110
+ }
111
+ Document.cloneDocument = cloneDocument;
112
+ })(Document || (Document = {}));
113
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1,12 @@
1
+ import type { Element } from "../element.js";
2
+ /**
3
+ * {@link https://html.spec.whatwg.org/#attr-input-type}
4
+ *
5
+ * @internal
6
+ */
7
+ export type InputType = "hidden" | "search" | "tel" | "url" | "email" | "password" | "date" | "month" | "week" | "time" | "datetime-local" | "number" | "range" | "color" | "checkbox" | "radio" | "file" | "submit" | "image" | "reset" | "button" | "text";
8
+ /**
9
+ * @public
10
+ */
11
+ export declare function inputType(element: Element<"input">): InputType;
12
+ //# sourceMappingURL=input-type.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @public
3
+ */
4
+ export function inputType(element) {
5
+ return element
6
+ .attribute("type")
7
+ .flatMap((attribute) => attribute.enumerate("hidden", "search", "tel", "url", "email", "password", "date", "month", "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", "file", "submit", "image", "reset", "button", "text"))
8
+ .getOr("text");
9
+ }
10
+ //# sourceMappingURL=input-type.js.map
@@ -0,0 +1,12 @@
1
+ import { Predicate } from "@siteimprove/alfa-predicate";
2
+ import type { Attribute } from "../../attribute.js";
3
+ import type { Element } from "../../element.js";
4
+ /**
5
+ * @public
6
+ */
7
+ export declare function hasAttribute(predicate: Predicate<Attribute>): Predicate<Element>;
8
+ /**
9
+ * @public
10
+ */
11
+ export declare function hasAttribute(name: string, value?: Predicate<string>): Predicate<Element>;
12
+ //# sourceMappingURL=has-attribute.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { Predicate } from "@siteimprove/alfa-predicate";
2
+ const { property } = Predicate;
3
+ export function hasAttribute(nameOrPredicate, value = () => true) {
4
+ if (typeof nameOrPredicate === "function") {
5
+ return (element) => element.attribute(nameOrPredicate).isSome();
6
+ }
7
+ const name = nameOrPredicate;
8
+ const predicate = property("value", value);
9
+ return (element) => element.attribute(name).some(predicate);
10
+ }
11
+ //# sourceMappingURL=has-attribute.js.map
@@ -0,0 +1,9 @@
1
+ import type { Device } from "@siteimprove/alfa-device";
2
+ import type { Predicate } from "@siteimprove/alfa-predicate";
3
+ import type { Rectangle } from "@siteimprove/alfa-rectangle";
4
+ import type { Element } from "../../element.js";
5
+ /**
6
+ * @public
7
+ */
8
+ export declare function hasBox(predicate: Predicate<Rectangle> | undefined, device: Device): Predicate<Element>;
9
+ //# sourceMappingURL=has-box.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @public
3
+ */
4
+ export function hasBox(predicate = () => true, device) {
5
+ return (element) => element.getBoundingBox(device).some(predicate);
6
+ }
7
+ //# sourceMappingURL=has-box.js.map
@@ -0,0 +1,7 @@
1
+ import type { Predicate } from "@siteimprove/alfa-predicate";
2
+ import type { Element } from "../../element.js";
3
+ /**
4
+ * @public
5
+ */
6
+ export declare function hasDisplaySize(valueOrPredicate: number | Predicate<number>): Predicate<Element>;
7
+ //# sourceMappingURL=has-display-size.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { None, Option } from "@siteimprove/alfa-option";
2
+ /**
3
+ * @public
4
+ */
5
+ export function hasDisplaySize(valueOrPredicate) {
6
+ const predicate = typeof valueOrPredicate === "function"
7
+ ? valueOrPredicate
8
+ : (size) => valueOrPredicate === size;
9
+ return (element) => {
10
+ const displaySize = element
11
+ .attribute("size")
12
+ .flatMap((size) => {
13
+ const sizeValue = parseInt(size.value, 10);
14
+ if (sizeValue === sizeValue && sizeValue === (sizeValue | 0)) {
15
+ return Option.of(sizeValue);
16
+ }
17
+ else {
18
+ return None;
19
+ }
20
+ })
21
+ .getOrElse(() => element
22
+ .attribute("multiple")
23
+ .map(() => 4)
24
+ .getOr(1));
25
+ return predicate(displaySize);
26
+ };
27
+ }
28
+ //# sourceMappingURL=has-display-size.js.map
@@ -0,0 +1,16 @@
1
+ import { Iterable } from "@siteimprove/alfa-iterable";
2
+ import { Predicate } from "@siteimprove/alfa-predicate";
3
+ import type { Element } from "../../element.js";
4
+ /**
5
+ * @public
6
+ */
7
+ export declare function hasId(predicate?: Predicate<string>): Predicate<Element>;
8
+ /**
9
+ * @public
10
+ */
11
+ export declare function hasId(id: string, ...rest: Array<string>): Predicate<Element>;
12
+ /**
13
+ * @public
14
+ */
15
+ export declare function hasId(ids: Iterable<string>): Predicate<Element>;
16
+ //# sourceMappingURL=has-id.d.ts.map