@siteimprove/alfa-dom 0.112.0 → 0.113.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/h.d.ts +14 -13
  3. package/dist/h.js +15 -13
  4. package/dist/index.d.ts +2 -28
  5. package/dist/index.js +2 -28
  6. package/dist/jsx.d.ts +2 -3
  7. package/dist/native.d.ts +10 -2
  8. package/dist/native.js +18 -2
  9. package/dist/node/attribute/predicate/has-name.d.ts +1 -1
  10. package/dist/node/attribute/predicate/has-name.js +2 -3
  11. package/dist/node/attribute.d.ts +9 -13
  12. package/dist/node/attribute.js +3 -10
  13. package/dist/node/comment.d.ts +7 -11
  14. package/dist/node/comment.js +2 -9
  15. package/dist/node/document.d.ts +11 -14
  16. package/dist/node/document.js +8 -23
  17. package/dist/node/element/augment.d.ts +1 -1
  18. package/dist/node/element/augment.js +1 -1
  19. package/dist/node/element/predicate/has-attribute.d.ts +1 -1
  20. package/dist/node/element/predicate/has-display-size.d.ts +1 -1
  21. package/dist/node/element/predicate/has-id.d.ts +1 -1
  22. package/dist/node/element/predicate/has-input-type.d.ts +1 -1
  23. package/dist/node/element/predicate/has-name.d.ts +1 -1
  24. package/dist/node/element/predicate/has-namespace.d.ts +1 -1
  25. package/dist/node/element/predicate/has-tab-index.d.ts +1 -1
  26. package/dist/node/element/predicate/has-unique-id.d.ts +3 -2
  27. package/dist/node/element/predicate/has-unique-id.js +21 -20
  28. package/dist/node/element/predicate/index.d.ts +19 -0
  29. package/dist/node/element/predicate/index.js +19 -0
  30. package/dist/node/element/predicate/is-actually-disabled.d.ts +4 -2
  31. package/dist/node/element/predicate/is-actually-disabled.js +37 -38
  32. package/dist/node/element/predicate/is-browsing-context-container.d.ts +1 -1
  33. package/dist/node/element/predicate/is-content.d.ts +4 -2
  34. package/dist/node/element/predicate/is-content.js +2 -4
  35. package/dist/node/element/predicate/is-document-element.d.ts +3 -2
  36. package/dist/node/element/predicate/is-document-element.js +2 -3
  37. package/dist/node/element/predicate/is-draggable.d.ts +1 -1
  38. package/dist/node/element/predicate/is-editing-host.d.ts +1 -1
  39. package/dist/node/element/predicate/is-fallback.d.ts +5 -2
  40. package/dist/node/element/predicate/is-fallback.js +5 -6
  41. package/dist/node/element/predicate/is-replaced.d.ts +1 -1
  42. package/dist/node/element/predicate/is-scoped-to.d.ts +3 -2
  43. package/dist/node/element/predicate/is-scoped-to.js +5 -5
  44. package/dist/node/element/predicate/is-suggested-focusable.d.ts +1 -1
  45. package/dist/node/element/predicate/is-suggested-focusable.js +3 -3
  46. package/dist/node/fragment.d.ts +6 -9
  47. package/dist/node/fragment.js +5 -20
  48. package/dist/node/index.d.ts +56 -0
  49. package/dist/node/index.js +74 -0
  50. package/dist/{node.d.ts → node/node.d.ts} +40 -160
  51. package/dist/{node.js → node/node.js} +57 -92
  52. package/dist/node/predicate/has-box.d.ts +1 -2
  53. package/dist/node/predicate/has-child.d.ts +2 -2
  54. package/dist/node/predicate/has-child.js +2 -3
  55. package/dist/node/predicate/has-descendant.d.ts +2 -2
  56. package/dist/node/predicate/has-descendant.js +2 -3
  57. package/dist/node/predicate/has-inclusive-descendant.d.ts +2 -2
  58. package/dist/node/predicate/has-inclusive-descendant.js +2 -3
  59. package/dist/node/predicate/has-text-content.d.ts +2 -2
  60. package/dist/node/predicate/has-text-content.js +2 -3
  61. package/dist/node/predicate/index.d.ts +7 -0
  62. package/dist/node/predicate/index.js +7 -0
  63. package/dist/node/predicate/is-root.d.ts +1 -1
  64. package/dist/node/query/descendants.d.ts +10 -10
  65. package/dist/node/query/descendants.js +6 -6
  66. package/dist/node/query/element-id-map.d.ts +3 -3
  67. package/dist/node/query/index.d.ts +3 -3
  68. package/dist/node/shadow.d.ts +11 -14
  69. package/dist/node/shadow.js +9 -24
  70. package/dist/node/{element.d.ts → slotable/element.d.ts} +28 -27
  71. package/dist/node/{element.js → slotable/element.js} +40 -51
  72. package/dist/node/slotable/index.d.ts +12 -0
  73. package/dist/node/slotable/index.js +15 -0
  74. package/dist/node/slotable/slot.d.ts +21 -0
  75. package/dist/node/slotable/slot.js +23 -0
  76. package/dist/node/slotable/slotable.d.ts +31 -0
  77. package/dist/node/slotable/slotable.js +16 -0
  78. package/dist/node/{text.d.ts → slotable/text.d.ts} +8 -11
  79. package/dist/node/{text.js → slotable/text.js} +13 -10
  80. package/dist/node/traversal/get-nodes-between.d.ts +2 -2
  81. package/dist/node/traversal/get-nodes-between.js +30 -29
  82. package/dist/node/traversal/index.d.ts +2 -0
  83. package/dist/node/traversal/index.js +2 -0
  84. package/dist/node/traversal/lowest-common-ancestor.d.ts +2 -2
  85. package/dist/node/traversal/lowest-common-ancestor.js +2 -3
  86. package/dist/node/type.d.ts +6 -10
  87. package/dist/node/type.js +2 -9
  88. package/dist/style/declaration.d.ts +2 -2
  89. package/dist/style/index.d.ts +5 -0
  90. package/dist/style/index.js +5 -0
  91. package/dist/style/rule/condition.d.ts +1 -1
  92. package/dist/style/rule/font-face.d.ts +3 -3
  93. package/dist/style/rule/font-face.js +2 -2
  94. package/dist/style/rule/grouping.d.ts +4 -3
  95. package/dist/style/rule/grouping.js +2 -2
  96. package/dist/style/rule/import.d.ts +3 -3
  97. package/dist/style/rule/import.js +2 -4
  98. package/dist/style/rule/index.d.ts +65 -0
  99. package/dist/style/rule/index.js +83 -0
  100. package/dist/style/rule/keyframe.d.ts +3 -3
  101. package/dist/style/rule/keyframe.js +2 -2
  102. package/dist/style/rule/keyframes.d.ts +2 -2
  103. package/dist/style/rule/keyframes.js +2 -3
  104. package/dist/style/rule/layer.d.ts +5 -4
  105. package/dist/style/rule/layer.js +4 -4
  106. package/dist/style/rule/media.d.ts +2 -2
  107. package/dist/style/rule/media.js +2 -3
  108. package/dist/style/rule/namespace.d.ts +3 -3
  109. package/dist/style/rule/namespace.js +2 -2
  110. package/dist/style/rule/page.d.ts +3 -3
  111. package/dist/style/rule/page.js +2 -2
  112. package/dist/style/rule/rule.d.ts +42 -0
  113. package/dist/style/rule/rule.js +64 -0
  114. package/dist/style/rule/style.d.ts +3 -3
  115. package/dist/style/rule/style.js +2 -2
  116. package/dist/style/rule/supports.d.ts +2 -2
  117. package/dist/style/rule/supports.js +2 -3
  118. package/dist/style/sheet.d.ts +1 -1
  119. package/dist/style/sheet.js +2 -2
  120. package/package.json +29 -30
  121. package/dist/node/element/predicate.d.ts +0 -19
  122. package/dist/node/element/predicate.js +0 -19
  123. package/dist/node/predicate.d.ts +0 -7
  124. package/dist/node/predicate.js +0 -7
  125. package/dist/node/slot.d.ts +0 -29
  126. package/dist/node/slot.js +0 -41
  127. package/dist/node/slotable.d.ts +0 -29
  128. package/dist/node/slotable.js +0 -40
  129. package/dist/node/traversal.d.ts +0 -2
  130. package/dist/node/traversal.js +0 -2
  131. package/dist/style/rule.d.ts +0 -60
  132. package/dist/style/rule.js +0 -109
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @siteimprove/alfa-dom
2
2
 
3
+ ## 0.113.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **Added:** Style rule subclasses now export their factory functions and type guards directly from the `Rule` namespace, e.g. use `Rule.media` (resp. `Rule.isMediaRule`) as an alias for `Rule.Media.of` (resp. `Rule.Media.isMediaRule`). ([#2040](https://github.com/Siteimprove/alfa/pull/2040))
8
+
9
+ - **Breaking:** The abstract class `Rule` has been renamed `BaseRule`; a new type `Rule`, being the union of actual concrete rules is now available. This should have no impact unless trying to extend the abstract class. ([#2040](https://github.com/Siteimprove/alfa/pull/2040))
10
+
11
+ - **Breaking:** The various subclasses of style rules are now exported as `Rule.Media`, … instead of `MediaRule`, … ([#2040](https://github.com/Siteimprove/alfa/pull/2040))
12
+
13
+ - **Breaking:** The `Slot` interface is now just a type alias for `Element<"slot">`. The `Slot.foo` functions are now `Slot#foo` methods; The `Slot.findSlottable` function/method has been removed as it is just an alias for `Slot#assignedNodes`. ([#2040](https://github.com/Siteimprove/alfa/pull/2040))
14
+
15
+ - **Breaking:** The `Node.clone` function has been deleted, as it wasn't used. ([#2040](https://github.com/Siteimprove/alfa/pull/2040))
16
+
17
+ - **Breaking:** `Rule.from` now requires a style sheet factory function as second argument; simply use `Sheet.of`. ([#2040](https://github.com/Siteimprove/alfa/pull/2040))
18
+
19
+ - **Breaking:** The `Slotable` interface is now an intermediate abstract class between `Node` and `Element`/`Text`. The `Slotable.foo` functions are now `Slotable#foo` methods; The `Slotable.findSlot` function/method has been removed as it is just an alias for `Slotable#assignedSlot`. ([#2040](https://github.com/Siteimprove/alfa/pull/2040))
20
+
21
+ - **Breaking:** A new required property `node` has been added to the `TextGroup` interface. ([#2047](https://github.com/Siteimprove/alfa/pull/2047))
22
+
23
+ ### Patch Changes
24
+
25
+ - **Added:** `Native.fromNode()` now accepts an `injectDataAlfaId` option. If set, every element in the page will be updated by adding a `data-alfa-id` attribute whose value matches the `internalId` of the corresponding Alfa `Element`. This allows for easier matching of test targets with the original DOM element. ([#2010](https://github.com/Siteimprove/alfa/pull/2010))
26
+
3
27
  ## 0.112.0
4
28
 
5
29
  ## 0.111.0
package/dist/h.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Device } from "@siteimprove/alfa-device";
2
2
  import type { Rectangle } from "@siteimprove/alfa-rectangle";
3
- import type { Node, Rule } from "./index.js";
4
- import { Attribute, Block, Declaration, Document, Element, FontFaceRule, Fragment, ImportRule, KeyframeRule, KeyframesRule, Layer, MediaRule, Namespace, NamespaceRule, PageRule, Shadow, Sheet, StyleRule, SupportsRule, Text, Type } from "./index.js";
3
+ import { Namespace } from "./namespace.js";
4
+ import { Attribute, Document, Element, Fragment, type Node, Shadow, Text, Type } from "./node/index.js";
5
+ import { Block, Declaration, Rule, Sheet } from "./style/index.js";
5
6
  /**
6
7
  * @public
7
8
  */
@@ -21,17 +22,17 @@ export declare namespace h {
21
22
  function block(declarations: Array<Declaration> | Record<string, string>): Block;
22
23
  function declaration(name: string, value: string, important?: boolean): Declaration;
23
24
  namespace rule {
24
- function fontFace(declarations: Array<Declaration> | Record<string, string>): FontFaceRule;
25
- function importRule(url: string, sheet: Sheet, mediaCondition?: string, supportCondition?: string, layer?: string): ImportRule;
26
- function keyframe(key: string, declarations: Array<Declaration> | Record<string, string>): KeyframeRule;
27
- function keyframes(name: string, rules: Array<Rule>): KeyframesRule;
28
- function layerBlock(rules: Array<Rule>, layer?: string): Layer.BlockRule;
29
- function layerStatement(layers: Array<string>): Layer.StatementRule;
30
- function media(condition: string, rules: Array<Rule>): MediaRule;
31
- function namespace(namespace: string, prefix?: string): NamespaceRule;
32
- function page(selector: string, declarations: Array<Declaration> | Record<string, string>): PageRule;
33
- function style(selector: string, declarations: Array<Declaration> | Record<string, string>, hint?: boolean): StyleRule;
34
- function supports(condition: string, rules: Array<Rule>): SupportsRule;
25
+ function fontFace(declarations: Array<Declaration> | Record<string, string>): Rule.FontFace;
26
+ function importRule(url: string, sheet: Sheet, mediaCondition?: string, supportCondition?: string, layer?: string): Rule.Import;
27
+ function keyframe(key: string, declarations: Array<Declaration> | Record<string, string>): Rule.Keyframe;
28
+ function keyframes(name: string, rules: Array<Rule>): Rule.Keyframes;
29
+ function layerBlock(rules: Array<Rule>, layer?: string): Rule.Layer.Block;
30
+ function layerStatement(layers: Array<string>): Rule.Layer.Statement;
31
+ function media(condition: string, rules: Array<Rule>): Rule.Media;
32
+ function namespace(namespace: string, prefix?: string): Rule.Namespace;
33
+ function page(selector: string, declarations: Array<Declaration> | Record<string, string>): Rule.Page;
34
+ function style(selector: string, declarations: Array<Declaration> | Record<string, string>, hint?: boolean): Rule.Style;
35
+ function supports(condition: string, rules: Array<Rule>): Rule.Supports;
35
36
  }
36
37
  }
37
38
  //# sourceMappingURL=h.d.ts.map
package/dist/h.js CHANGED
@@ -1,7 +1,9 @@
1
+ import { Device } from "@siteimprove/alfa-device";
1
2
  import { None, Option } from "@siteimprove/alfa-option";
2
3
  import { Predicate } from "@siteimprove/alfa-predicate";
3
- import { Device } from "@siteimprove/alfa-device";
4
- import { Attribute, Block, Declaration, Document, Element, FontFaceRule, Fragment, ImportRule, KeyframeRule, KeyframesRule, Layer, MediaRule, Namespace, NamespaceRule, PageRule, Shadow, Sheet, StyleRule, SupportsRule, Text, Type, } from "./index.js";
4
+ import { Namespace } from "./namespace.js";
5
+ import { Attribute, Document, Element, Fragment, Shadow, Text, Type, } from "./node/index.js";
6
+ import { Block, Declaration, Rule, Sheet } from "./style/index.js";
5
7
  const { entries } = Object;
6
8
  const { nor } = Predicate;
7
9
  /**
@@ -103,49 +105,49 @@ export function h(name, attributes, children, style, box, device = Device.standa
103
105
  let rule;
104
106
  (function (rule) {
105
107
  function fontFace(declarations) {
106
- return FontFaceRule.of(block(declarations));
108
+ return Rule.fontFace(block(declarations));
107
109
  }
108
110
  rule.fontFace = fontFace;
109
111
  function importRule(url, sheet, mediaCondition, supportCondition,
110
112
  // Use "" for anonymous layer.
111
113
  layer) {
112
- return ImportRule.of(url, sheet, Option.from(mediaCondition), Option.from(supportCondition), Option.from(layer));
114
+ return Rule.importRule(url, sheet, Option.from(mediaCondition), Option.from(supportCondition), Option.from(layer));
113
115
  }
114
116
  rule.importRule = importRule;
115
117
  function keyframe(key, declarations) {
116
- return KeyframeRule.of(key, block(declarations));
118
+ return Rule.keyframe(key, block(declarations));
117
119
  }
118
120
  rule.keyframe = keyframe;
119
121
  function keyframes(name, rules) {
120
- return KeyframesRule.of(name, rules);
122
+ return Rule.keyframes(name, rules);
121
123
  }
122
124
  rule.keyframes = keyframes;
123
125
  function layerBlock(rules, layer) {
124
- return Layer.BlockRule.of(rules, layer);
126
+ return Rule.layerBlock(rules, layer);
125
127
  }
126
128
  rule.layerBlock = layerBlock;
127
129
  function layerStatement(layers) {
128
- return Layer.StatementRule.of(layers);
130
+ return Rule.layerStatement(layers);
129
131
  }
130
132
  rule.layerStatement = layerStatement;
131
133
  function media(condition, rules) {
132
- return MediaRule.of(condition, rules);
134
+ return Rule.media(condition, rules);
133
135
  }
134
136
  rule.media = media;
135
137
  function namespace(namespace, prefix) {
136
- return NamespaceRule.of(namespace, Option.from(prefix));
138
+ return Rule.namespace(namespace, Option.from(prefix));
137
139
  }
138
140
  rule.namespace = namespace;
139
141
  function page(selector, declarations) {
140
- return PageRule.of(selector, block(declarations));
142
+ return Rule.page(selector, block(declarations));
141
143
  }
142
144
  rule.page = page;
143
145
  function style(selector, declarations, hint) {
144
- return StyleRule.of(selector, block(declarations), hint);
146
+ return Rule.style(selector, block(declarations), hint);
145
147
  }
146
148
  rule.style = style;
147
149
  function supports(condition, rules) {
148
- return SupportsRule.of(condition, rules);
150
+ return Rule.supports(condition, rules);
149
151
  }
150
152
  rule.supports = supports;
151
153
  })(rule = h.rule || (h.rule = {}));
package/dist/index.d.ts CHANGED
@@ -1,32 +1,6 @@
1
1
  export * from "./namespace.js";
2
- export * from "./style/block.js";
3
- export * from "./style/declaration.js";
4
- export * from "./style/rule.js";
5
- export * from "./style/rule/grouping.js";
6
- export * from "./style/rule/condition.js";
7
- export * from "./style/rule/font-face.js";
8
- export * from "./style/rule/import.js";
9
- export * from "./style/rule/keyframe.js";
10
- export * from "./style/rule/keyframes.js";
11
- export * from "./style/rule/layer.js";
12
- export * from "./style/rule/media.js";
13
- export * from "./style/rule/namespace.js";
14
- export * from "./style/rule/page.js";
15
- export * from "./style/rule/style.js";
16
- export * from "./style/rule/supports.js";
17
- export * from "./style/sheet.js";
18
- export * from "./node.js";
19
- export * from "./node/slot.js";
20
- export * from "./node/slotable.js";
21
- export * from "./node/attribute.js";
22
- export * from "./node/comment.js";
23
- export * from "./node/document.js";
24
- export * from "./node/element.js";
25
- import "./node/element/augment.js";
26
- export * from "./node/fragment.js";
27
- export * from "./node/shadow.js";
28
- export * from "./node/text.js";
29
- export * from "./node/type.js";
2
+ export * from "./style/index.js";
3
+ export * from "./node/index.js";
30
4
  export * from "./node/query/index.js";
31
5
  export { h } from "./h.js";
32
6
  export * from "./jsx.js";
package/dist/index.js CHANGED
@@ -1,32 +1,6 @@
1
1
  export * from "./namespace.js";
2
- export * from "./style/block.js";
3
- export * from "./style/declaration.js";
4
- export * from "./style/rule.js";
5
- export * from "./style/rule/grouping.js";
6
- export * from "./style/rule/condition.js";
7
- export * from "./style/rule/font-face.js";
8
- export * from "./style/rule/import.js";
9
- export * from "./style/rule/keyframe.js";
10
- export * from "./style/rule/keyframes.js";
11
- export * from "./style/rule/layer.js";
12
- export * from "./style/rule/media.js";
13
- export * from "./style/rule/namespace.js";
14
- export * from "./style/rule/page.js";
15
- export * from "./style/rule/style.js";
16
- export * from "./style/rule/supports.js";
17
- export * from "./style/sheet.js";
18
- export * from "./node.js";
19
- export * from "./node/slot.js";
20
- export * from "./node/slotable.js";
21
- export * from "./node/attribute.js";
22
- export * from "./node/comment.js";
23
- export * from "./node/document.js";
24
- export * from "./node/element.js";
25
- import "./node/element/augment.js";
26
- export * from "./node/fragment.js";
27
- export * from "./node/shadow.js";
28
- export * from "./node/text.js";
29
- export * from "./node/type.js";
2
+ export * from "./style/index.js";
3
+ export * from "./node/index.js";
30
4
  export * from "./node/query/index.js";
31
5
  export { h } from "./h.js";
32
6
  export * from "./jsx.js";
package/dist/jsx.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- import type { Element, Node } from "./index.js";
2
1
  import type * as dom from "./index.js";
3
2
  /**
4
3
  * @public
5
4
  */
6
- export declare function jsx<N extends string = string>(name: N, properties?: jsx.Properties | null, ...children: jsx.Children): Element<N>;
5
+ export declare function jsx<N extends string = string>(name: N, properties?: jsx.Properties | null, ...children: jsx.Children): dom.Element<N>;
7
6
  /**
8
7
  * @public
9
8
  */
10
9
  export declare namespace jsx {
11
- type Child = Node | string;
10
+ type Child = dom.Node | string;
12
11
  /**
13
12
  * @remarks
14
13
  * This type is declared using the short array syntax (`[]`) to avoid issues
package/dist/native.d.ts CHANGED
@@ -29,15 +29,23 @@ export declare namespace Native {
29
29
  function fromNode(node: globalThis.Node, options?: Options): Promise<Node.JSON & Logs>;
30
30
  interface Options {
31
31
  /**
32
- * Deprecated, use enforceAnonymousCrossOrigin instead
32
+ * Deprecated, use enforceAnonymousCrossOrigin instead.
33
33
  *
34
34
  * @deprecated
35
35
  */
36
36
  withCrossOrigin?: boolean;
37
37
  /**
38
- * Whether to enforce anonymous crossorigin attribute on <link> missing one
38
+ * Whether to enforce anonymous crossorigin attribute on <link> missing one.
39
+ *
40
+ * @defaultValue false
39
41
  */
40
42
  enforceAnonymousCrossOrigin?: boolean;
43
+ /**
44
+ * Whether to inject data-alfa-id attributes on elements of the page.
45
+ *
46
+ * @defaultValue false
47
+ */
48
+ injectDataAlfaId?: boolean;
41
49
  }
42
50
  }
43
51
  export {};
package/dist/native.js CHANGED
@@ -6,7 +6,7 @@ export var Native;
6
6
  (function (Native) {
7
7
  async function fromNode(node = globalThis.window.document, options) {
8
8
  const logs = [];
9
- const { withCrossOrigin = false, enforceAnonymousCrossOrigin = withCrossOrigin, } = options ?? {};
9
+ const { withCrossOrigin = false, enforceAnonymousCrossOrigin = withCrossOrigin, injectDataAlfaId = false, } = options ?? {};
10
10
  const range = globalThis.document.createRange(); // Used by toText - the same instance can be reused for each text node.
11
11
  return { ...(await toNode(node)), logs };
12
12
  async function toNode(node) {
@@ -27,7 +27,7 @@ export var Native;
27
27
  throw new Error(`Unsupported node of type: ${node.nodeType}`);
28
28
  }
29
29
  async function toElement(element) {
30
- return {
30
+ const result = {
31
31
  type: "element",
32
32
  namespace: element.namespaceURI,
33
33
  prefix: element.prefix,
@@ -43,6 +43,22 @@ export var Native;
43
43
  : null,
44
44
  box: toRectangle(element.getBoundingClientRect()),
45
45
  };
46
+ if (injectDataAlfaId) {
47
+ const internalId = globalThis.crypto.randomUUID();
48
+ // Add the internal ID to the result.
49
+ result.internalId = internalId;
50
+ // Add the data-alfa-id attribute to the result.
51
+ result.attributes.push({
52
+ type: "attribute",
53
+ namespace: null,
54
+ prefix: null,
55
+ name: "data-alfa-id",
56
+ value: internalId,
57
+ });
58
+ // Add the data-alfa-id attribute to the element in the page.
59
+ element.setAttribute("data-alfa-id", internalId);
60
+ }
61
+ return result;
46
62
  }
47
63
  function toAttribute(attribute) {
48
64
  return {
@@ -1,5 +1,5 @@
1
1
  import type { Refinement } from "@siteimprove/alfa-refinement";
2
- import { Attribute } from "../../attribute.js";
2
+ import type { Attribute } from "../../attribute.js";
3
3
  /**
4
4
  * @public
5
5
  */
@@ -1,4 +1,3 @@
1
- import { Attribute } from "../../attribute.js";
2
1
  export function hasName(nameOrPredicate, ...names) {
3
2
  let predicate;
4
3
  if (typeof nameOrPredicate === "function") {
@@ -6,8 +5,8 @@ export function hasName(nameOrPredicate, ...names) {
6
5
  }
7
6
  else {
8
7
  names.unshift(nameOrPredicate);
9
- predicate = (name, attribute) => names.some((candidate) => Attribute.foldCase(candidate, attribute.owner) === name);
8
+ predicate = (name) => names.some((candidate) => candidate === name);
10
9
  }
11
- return (attribute) => predicate(attribute.name, attribute);
10
+ return (attribute) => predicate(attribute.name);
12
11
  }
13
12
  //# sourceMappingURL=has-name.js.map
@@ -3,14 +3,14 @@ import { Sequence } from "@siteimprove/alfa-sequence";
3
3
  import { Trampoline } from "@siteimprove/alfa-trampoline";
4
4
  import * as json from "@siteimprove/alfa-json";
5
5
  import { Namespace } from "../namespace.js";
6
- import { Node } from "../node.js";
7
- import type { Element } from "./element.js";
6
+ import { BaseNode } from "./node.js";
7
+ import type { Element } from "./slotable/element.js";
8
8
  import * as predicate from "./attribute/predicate.js";
9
9
  import * as autocomplete from "./attribute/autocomplete.js";
10
10
  /**
11
11
  * @public
12
12
  */
13
- export declare class Attribute<N extends string = string> extends Node<"attribute"> {
13
+ export declare class Attribute<N extends string = string> extends BaseNode<"attribute"> {
14
14
  static of<N extends string = string>(namespace: Option<Namespace>, prefix: Option<string>, name: N, value: string, externalId?: string, internalId?: string, extraData?: any): Attribute<N>;
15
15
  private readonly _namespace;
16
16
  private readonly _prefix;
@@ -31,7 +31,7 @@ export declare class Attribute<N extends string = string> extends Node<"attribut
31
31
  /**
32
32
  * @internal
33
33
  **/
34
- protected _internalPath(options?: Node.Traversal): string;
34
+ protected _internalPath(options?: BaseNode.Traversal): string;
35
35
  /**
36
36
  * {@link https://html.spec.whatwg.org/#space-separated-tokens}
37
37
  */
@@ -44,10 +44,10 @@ export declare class Attribute<N extends string = string> extends Node<"attribut
44
44
  * {@link https://html.spec.whatwg.org/#enumerated-attribute}
45
45
  */
46
46
  enumerate<T extends string>(valid: T, ...rest: Array<T>): Option<T>;
47
- toJSON(options: Node.SerializationOptions & {
47
+ toJSON(options: BaseNode.SerializationOptions & {
48
48
  verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
49
49
  }): Attribute.MinimalJSON;
50
- toJSON(options?: Node.SerializationOptions): Attribute.JSON<N>;
50
+ toJSON(options?: BaseNode.SerializationOptions): Attribute.JSON<N>;
51
51
  toString(): string;
52
52
  /**
53
53
  * @internal
@@ -62,9 +62,9 @@ export declare class Attribute<N extends string = string> extends Node<"attribut
62
62
  * @public
63
63
  */
64
64
  export declare namespace Attribute {
65
- interface MinimalJSON extends Node.JSON<"attribute"> {
65
+ interface MinimalJSON extends BaseNode.JSON<"attribute"> {
66
66
  }
67
- interface JSON<N extends string = string> extends Node.JSON<"attribute"> {
67
+ interface JSON<N extends string = string> extends BaseNode.JSON<"attribute"> {
68
68
  namespace: string | null;
69
69
  prefix: string | null;
70
70
  name: N;
@@ -75,13 +75,9 @@ export declare namespace Attribute {
75
75
  * @internal
76
76
  */
77
77
  function fromAttribute<N extends string = string>(attribute: JSON<N>): Trampoline<Attribute<N>>;
78
- /**
79
- * @internal
80
- */
81
- function cloneAttribute<N extends string = string>(attribute: Attribute<N>): Trampoline<Attribute<N | Lowercase<N>>>;
82
78
  /**
83
79
  * Conditionally fold the case of an attribute name based on its owner; HTML
84
- * attributes are case insensitive while attributes in other namespaces aren't.
80
+ * attributes are case-insensitive while attributes in other namespaces aren't.
85
81
  *
86
82
  * @internal
87
83
  */
@@ -5,7 +5,7 @@ import { Sequence } from "@siteimprove/alfa-sequence";
5
5
  import { Trampoline } from "@siteimprove/alfa-trampoline";
6
6
  import * as json from "@siteimprove/alfa-json";
7
7
  import { Namespace } from "../namespace.js";
8
- import { Node } from "../node.js";
8
+ import { BaseNode } from "./node.js";
9
9
  import * as predicate from "./attribute/predicate.js";
10
10
  import * as autocomplete from "./attribute/autocomplete.js";
11
11
  const { isEmpty } = Iterable;
@@ -13,7 +13,7 @@ const { equals, not } = Predicate;
13
13
  /**
14
14
  * @public
15
15
  */
16
- export class Attribute extends Node {
16
+ export class Attribute extends BaseNode {
17
17
  static of(namespace, prefix, name, value, externalId, internalId, extraData) {
18
18
  return new Attribute(namespace, prefix, name, value, externalId, internalId, extraData);
19
19
  }
@@ -141,16 +141,9 @@ export class Attribute extends Node {
141
141
  return Trampoline.done(Attribute.of(Option.from(attribute.namespace), Option.from(attribute.prefix), attribute.name, attribute.value, attribute.externalId, attribute.internalId));
142
142
  }
143
143
  Attribute.fromAttribute = fromAttribute;
144
- /**
145
- * @internal
146
- */
147
- function cloneAttribute(attribute) {
148
- return Trampoline.done(Attribute.of(attribute.namespace, attribute.prefix, attribute.name, attribute.value, attribute.externalId, attribute.internalId, attribute.extraData));
149
- }
150
- Attribute.cloneAttribute = cloneAttribute;
151
144
  /**
152
145
  * Conditionally fold the case of an attribute name based on its owner; HTML
153
- * attributes are case insensitive while attributes in other namespaces aren't.
146
+ * attributes are case-insensitive while attributes in other namespaces aren't.
154
147
  *
155
148
  * @internal
156
149
  */
@@ -1,10 +1,10 @@
1
1
  import { Trampoline } from "@siteimprove/alfa-trampoline";
2
2
  import * as json from "@siteimprove/alfa-json";
3
- import { Node } from "../node.js";
3
+ import { BaseNode } from "./node.js";
4
4
  /**
5
5
  * @public
6
6
  */
7
- export declare class Comment extends Node<"comment"> {
7
+ export declare class Comment extends BaseNode<"comment"> {
8
8
  static of(data: string, externalId?: string, internalId?: string, extraData?: any): Comment;
9
9
  static empty(): Comment;
10
10
  private readonly _data;
@@ -13,20 +13,20 @@ export declare class Comment extends Node<"comment"> {
13
13
  /**
14
14
  * @internal
15
15
  **/
16
- protected _internalPath(options?: Node.Traversal): string;
17
- toJSON(options: Node.SerializationOptions & {
16
+ protected _internalPath(options?: BaseNode.Traversal): string;
17
+ toJSON(options: BaseNode.SerializationOptions & {
18
18
  verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
19
19
  }): Comment.MinimalJSON;
20
- toJSON(options?: Node.SerializationOptions): Comment.JSON;
20
+ toJSON(options?: BaseNode.SerializationOptions): Comment.JSON;
21
21
  toString(): string;
22
22
  }
23
23
  /**
24
24
  * @public
25
25
  */
26
26
  export declare namespace Comment {
27
- interface MinimalJSON extends Node.JSON<"comment"> {
27
+ interface MinimalJSON extends BaseNode.JSON<"comment"> {
28
28
  }
29
- interface JSON extends Node.JSON<"comment"> {
29
+ interface JSON extends BaseNode.JSON<"comment"> {
30
30
  data: string;
31
31
  }
32
32
  function isComment(value: unknown): value is Comment;
@@ -34,9 +34,5 @@ export declare namespace Comment {
34
34
  * @internal
35
35
  */
36
36
  function fromComment(json: JSON): Trampoline<Comment>;
37
- /**
38
- * @internal
39
- */
40
- function cloneComment(comment: Comment): Trampoline<Comment>;
41
37
  }
42
38
  //# sourceMappingURL=comment.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import { Trampoline } from "@siteimprove/alfa-trampoline";
2
2
  import * as json from "@siteimprove/alfa-json";
3
- import { Node } from "../node.js";
3
+ import { BaseNode } from "./node.js";
4
4
  /**
5
5
  * @public
6
6
  */
7
- export class Comment extends Node {
7
+ export class Comment extends BaseNode {
8
8
  static of(data, externalId, internalId, extraData) {
9
9
  return new Comment(data, externalId, internalId, extraData);
10
10
  }
@@ -63,12 +63,5 @@ export class Comment extends Node {
63
63
  return Trampoline.done(Comment.of(json.data, json.externalId, json.internalId));
64
64
  }
65
65
  Comment.fromComment = fromComment;
66
- /**
67
- * @internal
68
- */
69
- function cloneComment(comment) {
70
- return Trampoline.done(Comment.of(comment.data, comment.externalId, comment.internalId, comment.extraData));
71
- }
72
- Comment.cloneComment = cloneComment;
73
66
  })(Comment || (Comment = {}));
74
67
  //# sourceMappingURL=comment.js.map
@@ -4,13 +4,14 @@ import { Iterable } from "@siteimprove/alfa-iterable";
4
4
  import { Option } from "@siteimprove/alfa-option";
5
5
  import { Trampoline } from "@siteimprove/alfa-trampoline";
6
6
  import * as json from "@siteimprove/alfa-json";
7
- import { Node } from "../node.js";
7
+ import { BaseNode } from "./node.js";
8
8
  import { Sheet } from "../style/sheet.js";
9
- import { Element } from "./element.js";
9
+ import type { Element } from "./slotable/index.js";
10
+ import type { Node } from "./index.js";
10
11
  /**
11
12
  * @public
12
13
  */
13
- export declare class Document extends Node<"document"> {
14
+ export declare class Document extends BaseNode<"document"> {
14
15
  static of(children: Iterable<Node>, style?: Iterable<Sheet>, externalId?: string, internalId?: string, extraData?: any): Document;
15
16
  static empty(): Document;
16
17
  private readonly _style;
@@ -18,15 +19,15 @@ export declare class Document extends Node<"document"> {
18
19
  protected constructor(children: Array<Node>, style: Iterable<Sheet>, externalId?: string, internalId?: string, extraData?: any);
19
20
  get style(): Iterable<Sheet>;
20
21
  get frame(): Option<Element>;
21
- parent(options?: Node.Traversal): Option<Node>;
22
+ parent(options?: BaseNode.Traversal): Option<Node>;
22
23
  /**
23
24
  * @internal
24
25
  **/
25
- protected _internalPath(options?: Node.Traversal): string;
26
- toJSON(options: Node.SerializationOptions & {
26
+ protected _internalPath(options?: BaseNode.Traversal): string;
27
+ toJSON(options: BaseNode.SerializationOptions & {
27
28
  verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
28
29
  }): Document.MinimalJSON;
29
- toJSON(options?: Node.SerializationOptions): Document.JSON;
30
+ toJSON(options?: BaseNode.SerializationOptions): Document.JSON;
30
31
  toString(): string;
31
32
  /**
32
33
  * @internal
@@ -41,19 +42,15 @@ export declare class Document extends Node<"document"> {
41
42
  * @public
42
43
  */
43
44
  export declare namespace Document {
44
- interface MinimalJSON extends Node.JSON<"document"> {
45
+ interface MinimalJSON extends BaseNode.JSON<"document"> {
45
46
  }
46
- interface JSON extends Node.JSON<"document"> {
47
+ interface JSON extends BaseNode.JSON<"document"> {
47
48
  style: Array<Sheet.JSON>;
48
49
  }
49
50
  function isDocument(value: unknown): value is Document;
50
51
  /**
51
52
  * @internal
52
53
  */
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>;
54
+ function fromDocument(json: JSON, fromNode: (json: Node.JSON, device?: Device) => Trampoline<Node>, device?: Device): Trampoline<Document>;
58
55
  }
59
56
  //# sourceMappingURL=document.d.ts.map
@@ -4,13 +4,12 @@ import { None, Option } from "@siteimprove/alfa-option";
4
4
  import { String } from "@siteimprove/alfa-string";
5
5
  import { Trampoline } from "@siteimprove/alfa-trampoline";
6
6
  import * as json from "@siteimprove/alfa-json";
7
- import { Node } from "../node.js";
7
+ import { BaseNode } from "./node.js";
8
8
  import { Sheet } from "../style/sheet.js";
9
- import { Element } from "./element.js";
10
9
  /**
11
10
  * @public
12
11
  */
13
- export class Document extends Node {
12
+ export class Document extends BaseNode {
14
13
  static of(children, style = [], externalId, internalId, extraData) {
15
14
  return new Document(Array.from(children), style, externalId, internalId, extraData);
16
15
  }
@@ -29,16 +28,16 @@ export class Document extends Node {
29
28
  get frame() {
30
29
  return this._frame;
31
30
  }
32
- parent(options = Node.Traversal.empty) {
33
- return options.isSet(Node.Traversal.nested)
31
+ parent(options = BaseNode.Traversal.empty) {
32
+ return options.isSet(BaseNode.Traversal.nested)
34
33
  ? this.frame
35
34
  : super.parent(options);
36
35
  }
37
36
  /**
38
37
  * @internal
39
38
  **/
40
- _internalPath(options = Node.Traversal.empty) {
41
- if (options.isSet(Node.Traversal.nested)) {
39
+ _internalPath(options = BaseNode.Traversal.empty) {
40
+ if (options.isSet(BaseNode.Traversal.nested)) {
42
41
  return this._frame
43
42
  .map((frame) => frame.path(options) + "/document-node()")
44
43
  .getOr("/");
@@ -91,23 +90,9 @@ export class Document extends Node {
91
90
  /**
92
91
  * @internal
93
92
  */
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.internalId));
93
+ function fromDocument(json, fromNode, device) {
94
+ return Trampoline.traverse(json.children ?? [], (child) => fromNode(child, device)).map((children) => Document.of(children, json.style.map(Sheet.from), json.externalId, json.internalId));
96
95
  }
97
96
  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.internalId, document.extraData);
109
- });
110
- }
111
- Document.cloneDocument = cloneDocument;
112
97
  })(Document || (Document = {}));
113
98
  //# sourceMappingURL=document.js.map
@@ -1,6 +1,6 @@
1
1
  import { Sequence } from "@siteimprove/alfa-sequence";
2
2
  import type { InputType } from "./input-type.js";
3
- declare module "../element.js" {
3
+ declare module "../slotable/element.js" {
4
4
  interface Element<N extends string> {
5
5
  /**
6
6
  * {@link https://html.spec.whatwg.org/#attr-input-type}
@@ -8,7 +8,7 @@
8
8
  import { None, Some } from "@siteimprove/alfa-option";
9
9
  import { Refinement } from "@siteimprove/alfa-refinement";
10
10
  import { Sequence } from "@siteimprove/alfa-sequence";
11
- import { Element } from "../element.js";
11
+ import { Element } from "../slotable/element.js";
12
12
  const { isElement } = Element;
13
13
  const { and } = Refinement;
14
14
  Element.prototype.inputType = function () {