@siteimprove/alfa-dom 0.97.0 → 0.99.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @siteimprove/alfa-dom
2
2
 
3
+ ## 0.99.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **Added:** The `<search>` element is now correctly handled. ([#1759](https://github.com/Siteimprove/alfa/pull/1759))
8
+
9
+ ## 0.98.0
10
+
11
+ ### Minor Changes
12
+
13
+ - **Changed:** Node serialization with `Low` verbosity now also include the `Node#path`. ([#1748](https://github.com/Siteimprove/alfa/pull/1748))
14
+
15
+ ### Patch Changes
16
+
17
+ - **Changed:** Classes that do not implement the Singleton pattern now have `protected` constructor and can be extended. ([#1735](https://github.com/Siteimprove/alfa/pull/1735))
18
+
3
19
  ## 0.97.0
4
20
 
5
21
  ## 0.96.0
@@ -17,7 +17,7 @@ export declare class Attribute<N extends string = string> extends Node<"attribut
17
17
  private readonly _name;
18
18
  private readonly _value;
19
19
  private _owner;
20
- private constructor();
20
+ protected constructor(namespace: Option<Namespace>, prefix: Option<string>, name: N, value: string, externalId?: string, internalId?: string, extraData?: any);
21
21
  get namespace(): Option<Namespace>;
22
22
  get prefix(): Option<string>;
23
23
  get name(): N | Lowercase<N>;
@@ -8,7 +8,7 @@ export declare class Comment extends Node<"comment"> {
8
8
  static of(data: string, externalId?: string, internalId?: string, extraData?: any): Comment;
9
9
  static empty(): Comment;
10
10
  private readonly _data;
11
- private constructor();
11
+ protected constructor(data: string, externalId?: string, internalId?: string, extraData?: any);
12
12
  get data(): string;
13
13
  /**
14
14
  * @internal
@@ -15,7 +15,7 @@ export declare class Document extends Node<"document"> {
15
15
  static empty(): Document;
16
16
  private readonly _style;
17
17
  private _frame;
18
- private constructor();
18
+ protected constructor(children: Array<Node>, style: Iterable<Sheet>, externalId?: string, internalId?: string, extraData?: any);
19
19
  get style(): Iterable<Sheet>;
20
20
  get frame(): Option<Element>;
21
21
  parent(options?: Node.Traversal): Option<Node>;
@@ -31,7 +31,7 @@ export declare class Element<N extends string = string> extends Node<"element">
31
31
  private readonly _id;
32
32
  private readonly _classes;
33
33
  private readonly _boxes;
34
- private constructor();
34
+ protected constructor(namespace: Option<Namespace>, prefix: Option<string>, name: N, attributes: Array<Attribute>, children: Array<Node>, style: Option<Block>, box: Option<Rectangle>, device: Option<Device>, externalId?: string, internalId?: string, extraData?: any);
35
35
  get namespace(): Option<Namespace>;
36
36
  get prefix(): Option<string>;
37
37
  get name(): N;
@@ -8,7 +8,7 @@ import { Node } from "../node.js";
8
8
  export declare class Fragment extends Node<"fragment"> {
9
9
  static of(children: Iterable<Node>, externalId?: string, internalId?: string, extraData?: any): Fragment;
10
10
  static empty(): Fragment;
11
- private constructor();
11
+ protected constructor(children: Array<Node>, externalId?: string, internalId?: string, extraData?: any);
12
12
  /**
13
13
  * @internal
14
14
  **/
@@ -15,7 +15,7 @@ export declare class Shadow extends Node<"shadow"> {
15
15
  private readonly _mode;
16
16
  private _host;
17
17
  private readonly _style;
18
- private constructor();
18
+ protected constructor(children: Array<Node>, style: Array<Sheet>, mode: Shadow.Mode, externalId?: string, internalId?: string, extraData?: any);
19
19
  get mode(): Shadow.Mode;
20
20
  get host(): Option<Element>;
21
21
  get style(): Iterable<Sheet>;
@@ -11,7 +11,7 @@ export declare class Text extends Node<"text"> implements Slotable {
11
11
  static of(data: string, externalId?: string, internalId?: string, extraData?: any): Text;
12
12
  static empty(): Text;
13
13
  private readonly _data;
14
- private constructor();
14
+ protected constructor(data: string, externalId?: string, internalId?: string, extraData?: any);
15
15
  get data(): string;
16
16
  assignedSlot(): Option<Slot>;
17
17
  /**
@@ -11,7 +11,7 @@ export declare class Type<N extends string = string> extends Node<"type"> {
11
11
  private readonly _name;
12
12
  private readonly _publicId;
13
13
  private readonly _systemId;
14
- private constructor();
14
+ protected constructor(name: N, publicId: Option<string>, systemId: Option<string>, externalId?: string, internalId?: string, extraData?: any);
15
15
  get name(): N;
16
16
  get publicId(): Option<string>;
17
17
  get systemId(): Option<string>;
package/dist/node.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import type { Device } from "@siteimprove/alfa-device";
2
2
  import { Flags } from "@siteimprove/alfa-flags";
3
+ import { Serializable } from "@siteimprove/alfa-json";
3
4
  import { Option } from "@siteimprove/alfa-option";
4
5
  import type { Predicate } from "@siteimprove/alfa-predicate";
5
6
  import type { Refinement } from "@siteimprove/alfa-refinement";
6
7
  import { Sequence } from "@siteimprove/alfa-sequence";
7
8
  import type { Trampoline } from "@siteimprove/alfa-trampoline";
8
9
  import type * as earl from "@siteimprove/alfa-earl";
9
- import type * as json from "@siteimprove/alfa-json";
10
+ import * as json from "@siteimprove/alfa-json";
10
11
  import type * as sarif from "@siteimprove/alfa-sarif";
11
12
  import * as tree from "@siteimprove/alfa-tree";
12
13
  import { Attribute, Comment, Document, Element, Fragment, Shadow, Text, Type } from "./index.js";
@@ -40,6 +41,7 @@ export declare abstract class Node<T extends string = string> extends tree.Node<
40
41
  path(options?: Node.Traversal): string;
41
42
  equals(value: Node): boolean;
42
43
  equals(value: unknown): value is this;
44
+ toJSON(options?: Serializable.Options): Node.JSON<T>;
43
45
  toEARL(): Node.EARL;
44
46
  toSARIF(): sarif.Location;
45
47
  }
@@ -80,6 +82,7 @@ export interface Node {
80
82
  */
81
83
  export declare namespace Node {
82
84
  interface JSON<T extends string = string> extends tree.Node.JSON<T> {
85
+ path?: string;
83
86
  }
84
87
  interface SerializationOptions extends json.Serializable.Options {
85
88
  device?: Device;
package/dist/node.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { Cache } from "@siteimprove/alfa-cache";
2
2
  import { Comparable, Comparison, } from "@siteimprove/alfa-comparable";
3
3
  import { Flags } from "@siteimprove/alfa-flags";
4
+ import { Serializable } from "@siteimprove/alfa-json";
4
5
  import { Lazy } from "@siteimprove/alfa-lazy";
5
6
  import { Option } from "@siteimprove/alfa-option";
6
7
  import { Selective } from "@siteimprove/alfa-selective";
7
8
  import { Sequence } from "@siteimprove/alfa-sequence";
8
9
  import { String } from "@siteimprove/alfa-string";
10
+ import * as json from "@siteimprove/alfa-json";
9
11
  import * as tree from "@siteimprove/alfa-tree";
10
12
  import { Attribute, Comment, Document, Element, Fragment, Shadow, Slot, Slotable, Text, Type, } from "./index.js";
11
13
  import * as predicate from "./node/predicate.js";
@@ -107,10 +109,12 @@ export class Node extends tree.Node {
107
109
  * shadow tree or content document.
108
110
  *
109
111
  * @remarks
110
- * It is important that this expansion happens **after** sorting by tabindex
112
+ * It is important that this expansion happens **after** sorting by
113
+ * tabindex
111
114
  * since shadow DOM and content documents build their own sequential focus
112
- * order that is inserted as-is in the light tree or parent browsing context.
113
- * That is, a tabindex of 1 in a shadow tree or content document does
115
+ * order that is inserted as-is in the light tree or parent browsing
116
+ * context. That is, a tabindex of 1 in a shadow tree or content document
117
+ * does
114
118
  * **not** come before a tabindex of 2 in the main document.
115
119
  */
116
120
  function expand([element, tabIndex]) {
@@ -190,6 +194,16 @@ export class Node extends tree.Node {
190
194
  equals(value) {
191
195
  return value === this;
192
196
  }
197
+ toJSON(options) {
198
+ const verbosity = options?.verbosity ?? json.Serializable.Verbosity.Medium;
199
+ return {
200
+ ...super.toJSON(options),
201
+ ...(json.Serializable.Verbosity.Minimal < verbosity &&
202
+ verbosity < json.Serializable.Verbosity.Medium
203
+ ? { path: this.path(Node.composedNested) }
204
+ : {}),
205
+ };
206
+ }
193
207
  toEARL() {
194
208
  return {
195
209
  "@context": {
@@ -10,7 +10,7 @@ import { Declaration } from "./declaration.js";
10
10
  export declare class Block implements Iterable<Declaration>, Equatable, Serializable {
11
11
  static of(declarations: Iterable<Declaration>): Block;
12
12
  private _declarations;
13
- private constructor();
13
+ protected constructor(declarations: Array<Declaration>);
14
14
  get declarations(): Iterable<Declaration>;
15
15
  get size(): number;
16
16
  isEmpty(): boolean;
@@ -28,7 +28,7 @@ export declare class Declaration implements Equatable, Serializable {
28
28
  * Only one of _parent and _owner should be Some.
29
29
  */
30
30
  private _owner;
31
- private constructor();
31
+ protected constructor(name: string, value: string, important: boolean);
32
32
  get name(): string;
33
33
  get value(): string;
34
34
  get important(): boolean;
@@ -8,7 +8,7 @@ import { Rule } from "../rule.js";
8
8
  export declare class FontFaceRule extends Rule<"font-face"> {
9
9
  static of(declarations: Iterable<Declaration>): FontFaceRule;
10
10
  private readonly _style;
11
- private constructor();
11
+ protected constructor(declarations: Array<Declaration>);
12
12
  get style(): Block;
13
13
  toJSON(): FontFaceRule.JSON;
14
14
  toString(): string;
@@ -17,7 +17,7 @@ export declare class ImportRule extends ConditionRule<"import"> {
17
17
  private readonly _supportCondition;
18
18
  private readonly _supportQuery;
19
19
  private _layer;
20
- private constructor();
20
+ protected constructor(href: string, sheet: Sheet, mediaCondition: Option<string>, supportCondition: Option<string>, layer: Option<string>);
21
21
  get supportCondition(): Option<string>;
22
22
  get mediaQueries(): Feature.Media.List;
23
23
  get supportQuery(): Option<Option<Feature.Supports.Query>>;
@@ -9,7 +9,7 @@ export declare class KeyframeRule extends Rule<"keyframe"> {
9
9
  static of(key: string, declarations: Iterable<Declaration>): KeyframeRule;
10
10
  private readonly _key;
11
11
  private readonly _style;
12
- private constructor();
12
+ protected constructor(key: string, declarations: Array<Declaration>);
13
13
  get key(): string;
14
14
  get style(): Block;
15
15
  toJSON(): KeyframeRule.JSON;
@@ -7,7 +7,7 @@ import { GroupingRule } from "./grouping.js";
7
7
  export declare class KeyframesRule extends GroupingRule<"keyframes"> {
8
8
  static of(name: string, rules: Iterable<Rule>): KeyframesRule;
9
9
  private readonly _name;
10
- private constructor();
10
+ protected constructor(name: string, rules: Array<Rule>);
11
11
  get name(): string;
12
12
  toJSON(): KeyframesRule.JSON;
13
13
  toString(): string;
@@ -24,7 +24,7 @@ export declare namespace Layer {
24
24
  class StatementRule extends Rule<"layer-statement"> {
25
25
  static of(layers: Iterable<string>): StatementRule;
26
26
  private readonly _layers;
27
- private constructor();
27
+ protected constructor(layers: Array<string>);
28
28
  get layers(): Iterable<string>;
29
29
  toJSON(): StatementRule.JSON;
30
30
  toString(): string;
@@ -44,7 +44,7 @@ export declare namespace Layer {
44
44
  class BlockRule extends GroupingRule<"layer-block"> {
45
45
  static of(rules: Iterable<Rule>, layer?: string | null): BlockRule;
46
46
  private readonly _layer;
47
- private constructor();
47
+ protected constructor(layer: Option<string>, rules: Array<Rule>);
48
48
  get layer(): Option<string>;
49
49
  equals(value: unknown): value is this;
50
50
  toJSON(): BlockRule.JSON;
@@ -11,7 +11,7 @@ import { ConditionRule } from "./condition.js";
11
11
  export declare class MediaRule extends ConditionRule<"media"> {
12
12
  static of(condition: string, rules: Iterable<Rule>): MediaRule;
13
13
  private readonly _queries;
14
- private constructor();
14
+ protected constructor(condition: string, rules: Array<Rule>);
15
15
  get queries(): Feature.Media.List;
16
16
  toJSON(): MediaRule.JSON;
17
17
  toString(): string;
@@ -8,7 +8,7 @@ export declare class NamespaceRule extends Rule<"namespace"> {
8
8
  static of(namespace: string, prefix: Option<string>): NamespaceRule;
9
9
  private readonly _namespace;
10
10
  private readonly _prefix;
11
- private constructor();
11
+ protected constructor(namespace: string, prefix: Option<string>);
12
12
  get namespace(): string;
13
13
  get prefix(): Option<string>;
14
14
  toJSON(): NamespaceRule.JSON;
@@ -9,7 +9,7 @@ export declare class PageRule extends Rule<"page"> {
9
9
  static of(selector: string, declarations: Iterable<Declaration>): PageRule;
10
10
  private readonly _selector;
11
11
  private readonly _style;
12
- private constructor();
12
+ protected constructor(selector: string, declarations: Array<Declaration>);
13
13
  get selector(): string;
14
14
  get style(): Block;
15
15
  toJSON(): PageRule.JSON;
@@ -10,7 +10,7 @@ export declare class StyleRule extends Rule<"style"> {
10
10
  private readonly _selector;
11
11
  private readonly _style;
12
12
  private readonly _hint;
13
- private constructor();
13
+ protected constructor(selector: string, declarations: Array<Declaration>, hint: boolean);
14
14
  get selector(): string;
15
15
  get style(): Block;
16
16
  get hint(): boolean;
@@ -11,7 +11,7 @@ import type { Predicate } from "@siteimprove/alfa-predicate";
11
11
  export declare class SupportsRule extends ConditionRule<"supports"> {
12
12
  static of(condition: string, rules: Iterable<Rule>): SupportsRule;
13
13
  private readonly _query;
14
- private constructor();
14
+ protected constructor(condition: string, rules: Array<Rule>);
15
15
  get query(): Option<Feature.Supports.Query>;
16
16
  toJSON(): SupportsRule.JSON;
17
17
  toString(): string;
@@ -12,7 +12,7 @@ export declare class Sheet implements Equatable, Serializable {
12
12
  private _rules;
13
13
  private readonly _disabled;
14
14
  private readonly _condition;
15
- private constructor();
15
+ protected constructor(rules: Array<Rule>, disabled: boolean, condition: Option<string>);
16
16
  get rules(): Iterable<Rule>;
17
17
  get disabled(): boolean;
18
18
  get condition(): Option<string>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json.schemastore.org/package",
3
3
  "name": "@siteimprove/alfa-dom",
4
4
  "homepage": "https://alfa.siteimprove.com",
5
- "version": "0.97.0",
5
+ "version": "0.99.0",
6
6
  "license": "MIT",
7
7
  "description": "Implementations of the core DOM and CSSOM node types",
8
8
  "repository": {
@@ -35,37 +35,37 @@
35
35
  "dist/**/*.d.ts"
36
36
  ],
37
37
  "dependencies": {
38
- "@siteimprove/alfa-array": "^0.97.0",
39
- "@siteimprove/alfa-cache": "^0.97.0",
40
- "@siteimprove/alfa-comparable": "^0.97.0",
41
- "@siteimprove/alfa-css": "^0.97.0",
42
- "@siteimprove/alfa-css-feature": "^0.97.0",
43
- "@siteimprove/alfa-device": "^0.97.0",
44
- "@siteimprove/alfa-earl": "^0.97.0",
45
- "@siteimprove/alfa-equatable": "^0.97.0",
46
- "@siteimprove/alfa-flags": "^0.97.0",
47
- "@siteimprove/alfa-iterable": "^0.97.0",
48
- "@siteimprove/alfa-json": "^0.97.0",
49
- "@siteimprove/alfa-lazy": "^0.97.0",
50
- "@siteimprove/alfa-map": "^0.97.0",
51
- "@siteimprove/alfa-option": "^0.97.0",
52
- "@siteimprove/alfa-parser": "^0.97.0",
53
- "@siteimprove/alfa-predicate": "^0.97.0",
54
- "@siteimprove/alfa-rectangle": "^0.97.0",
55
- "@siteimprove/alfa-refinement": "^0.97.0",
56
- "@siteimprove/alfa-result": "^0.97.0",
57
- "@siteimprove/alfa-sarif": "^0.97.0",
58
- "@siteimprove/alfa-selective": "^0.97.0",
59
- "@siteimprove/alfa-sequence": "^0.97.0",
60
- "@siteimprove/alfa-slice": "^0.97.0",
61
- "@siteimprove/alfa-string": "^0.97.0",
62
- "@siteimprove/alfa-trampoline": "^0.97.0",
63
- "@siteimprove/alfa-tree": "^0.97.0"
38
+ "@siteimprove/alfa-array": "^0.99.0",
39
+ "@siteimprove/alfa-cache": "^0.99.0",
40
+ "@siteimprove/alfa-comparable": "^0.99.0",
41
+ "@siteimprove/alfa-css": "^0.99.0",
42
+ "@siteimprove/alfa-css-feature": "^0.99.0",
43
+ "@siteimprove/alfa-device": "^0.99.0",
44
+ "@siteimprove/alfa-earl": "^0.99.0",
45
+ "@siteimprove/alfa-equatable": "^0.99.0",
46
+ "@siteimprove/alfa-flags": "^0.99.0",
47
+ "@siteimprove/alfa-iterable": "^0.99.0",
48
+ "@siteimprove/alfa-json": "^0.99.0",
49
+ "@siteimprove/alfa-lazy": "^0.99.0",
50
+ "@siteimprove/alfa-map": "^0.99.0",
51
+ "@siteimprove/alfa-option": "^0.99.0",
52
+ "@siteimprove/alfa-parser": "^0.99.0",
53
+ "@siteimprove/alfa-predicate": "^0.99.0",
54
+ "@siteimprove/alfa-rectangle": "^0.99.0",
55
+ "@siteimprove/alfa-refinement": "^0.99.0",
56
+ "@siteimprove/alfa-result": "^0.99.0",
57
+ "@siteimprove/alfa-sarif": "^0.99.0",
58
+ "@siteimprove/alfa-selective": "^0.99.0",
59
+ "@siteimprove/alfa-sequence": "^0.99.0",
60
+ "@siteimprove/alfa-slice": "^0.99.0",
61
+ "@siteimprove/alfa-string": "^0.99.0",
62
+ "@siteimprove/alfa-trampoline": "^0.99.0",
63
+ "@siteimprove/alfa-tree": "^0.99.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@siteimprove/alfa-test": "^0.97.0",
66
+ "@siteimprove/alfa-test": "^0.99.0",
67
67
  "@types/jsdom": "^21.1.6",
68
- "jsdom": "^25.0.0"
68
+ "jsdom": "^26.0.0"
69
69
  },
70
70
  "publishConfig": {
71
71
  "access": "public",