@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.
- package/CHANGELOG.md +24 -0
- package/dist/h.d.ts +14 -13
- package/dist/h.js +15 -13
- package/dist/index.d.ts +2 -28
- package/dist/index.js +2 -28
- package/dist/jsx.d.ts +2 -3
- package/dist/native.d.ts +10 -2
- package/dist/native.js +18 -2
- package/dist/node/attribute/predicate/has-name.d.ts +1 -1
- package/dist/node/attribute/predicate/has-name.js +2 -3
- package/dist/node/attribute.d.ts +9 -13
- package/dist/node/attribute.js +3 -10
- package/dist/node/comment.d.ts +7 -11
- package/dist/node/comment.js +2 -9
- package/dist/node/document.d.ts +11 -14
- package/dist/node/document.js +8 -23
- package/dist/node/element/augment.d.ts +1 -1
- package/dist/node/element/augment.js +1 -1
- package/dist/node/element/predicate/has-attribute.d.ts +1 -1
- package/dist/node/element/predicate/has-display-size.d.ts +1 -1
- package/dist/node/element/predicate/has-id.d.ts +1 -1
- package/dist/node/element/predicate/has-input-type.d.ts +1 -1
- package/dist/node/element/predicate/has-name.d.ts +1 -1
- package/dist/node/element/predicate/has-namespace.d.ts +1 -1
- package/dist/node/element/predicate/has-tab-index.d.ts +1 -1
- package/dist/node/element/predicate/has-unique-id.d.ts +3 -2
- package/dist/node/element/predicate/has-unique-id.js +21 -20
- package/dist/node/element/predicate/index.d.ts +19 -0
- package/dist/node/element/predicate/index.js +19 -0
- package/dist/node/element/predicate/is-actually-disabled.d.ts +4 -2
- package/dist/node/element/predicate/is-actually-disabled.js +37 -38
- package/dist/node/element/predicate/is-browsing-context-container.d.ts +1 -1
- package/dist/node/element/predicate/is-content.d.ts +4 -2
- package/dist/node/element/predicate/is-content.js +2 -4
- package/dist/node/element/predicate/is-document-element.d.ts +3 -2
- package/dist/node/element/predicate/is-document-element.js +2 -3
- package/dist/node/element/predicate/is-draggable.d.ts +1 -1
- package/dist/node/element/predicate/is-editing-host.d.ts +1 -1
- package/dist/node/element/predicate/is-fallback.d.ts +5 -2
- package/dist/node/element/predicate/is-fallback.js +5 -6
- package/dist/node/element/predicate/is-replaced.d.ts +1 -1
- package/dist/node/element/predicate/is-scoped-to.d.ts +3 -2
- package/dist/node/element/predicate/is-scoped-to.js +5 -5
- package/dist/node/element/predicate/is-suggested-focusable.d.ts +1 -1
- package/dist/node/element/predicate/is-suggested-focusable.js +3 -3
- package/dist/node/fragment.d.ts +6 -9
- package/dist/node/fragment.js +5 -20
- package/dist/node/index.d.ts +56 -0
- package/dist/node/index.js +74 -0
- package/dist/{node.d.ts → node/node.d.ts} +40 -160
- package/dist/{node.js → node/node.js} +57 -92
- package/dist/node/predicate/has-box.d.ts +1 -2
- package/dist/node/predicate/has-child.d.ts +2 -2
- package/dist/node/predicate/has-child.js +2 -3
- package/dist/node/predicate/has-descendant.d.ts +2 -2
- package/dist/node/predicate/has-descendant.js +2 -3
- package/dist/node/predicate/has-inclusive-descendant.d.ts +2 -2
- package/dist/node/predicate/has-inclusive-descendant.js +2 -3
- package/dist/node/predicate/has-text-content.d.ts +2 -2
- package/dist/node/predicate/has-text-content.js +2 -3
- package/dist/node/predicate/index.d.ts +7 -0
- package/dist/node/predicate/index.js +7 -0
- package/dist/node/predicate/is-root.d.ts +1 -1
- package/dist/node/query/descendants.d.ts +10 -10
- package/dist/node/query/descendants.js +6 -6
- package/dist/node/query/element-id-map.d.ts +3 -3
- package/dist/node/query/index.d.ts +3 -3
- package/dist/node/shadow.d.ts +11 -14
- package/dist/node/shadow.js +9 -24
- package/dist/node/{element.d.ts → slotable/element.d.ts} +28 -27
- package/dist/node/{element.js → slotable/element.js} +40 -51
- package/dist/node/slotable/index.d.ts +12 -0
- package/dist/node/slotable/index.js +15 -0
- package/dist/node/slotable/slot.d.ts +21 -0
- package/dist/node/slotable/slot.js +23 -0
- package/dist/node/slotable/slotable.d.ts +31 -0
- package/dist/node/slotable/slotable.js +16 -0
- package/dist/node/{text.d.ts → slotable/text.d.ts} +8 -11
- package/dist/node/{text.js → slotable/text.js} +13 -10
- package/dist/node/traversal/get-nodes-between.d.ts +2 -2
- package/dist/node/traversal/get-nodes-between.js +30 -29
- package/dist/node/traversal/index.d.ts +2 -0
- package/dist/node/traversal/index.js +2 -0
- package/dist/node/traversal/lowest-common-ancestor.d.ts +2 -2
- package/dist/node/traversal/lowest-common-ancestor.js +2 -3
- package/dist/node/type.d.ts +6 -10
- package/dist/node/type.js +2 -9
- package/dist/style/declaration.d.ts +2 -2
- package/dist/style/index.d.ts +5 -0
- package/dist/style/index.js +5 -0
- package/dist/style/rule/condition.d.ts +1 -1
- package/dist/style/rule/font-face.d.ts +3 -3
- package/dist/style/rule/font-face.js +2 -2
- package/dist/style/rule/grouping.d.ts +4 -3
- package/dist/style/rule/grouping.js +2 -2
- package/dist/style/rule/import.d.ts +3 -3
- package/dist/style/rule/import.js +2 -4
- package/dist/style/rule/index.d.ts +65 -0
- package/dist/style/rule/index.js +83 -0
- package/dist/style/rule/keyframe.d.ts +3 -3
- package/dist/style/rule/keyframe.js +2 -2
- package/dist/style/rule/keyframes.d.ts +2 -2
- package/dist/style/rule/keyframes.js +2 -3
- package/dist/style/rule/layer.d.ts +5 -4
- package/dist/style/rule/layer.js +4 -4
- package/dist/style/rule/media.d.ts +2 -2
- package/dist/style/rule/media.js +2 -3
- package/dist/style/rule/namespace.d.ts +3 -3
- package/dist/style/rule/namespace.js +2 -2
- package/dist/style/rule/page.d.ts +3 -3
- package/dist/style/rule/page.js +2 -2
- package/dist/style/rule/rule.d.ts +42 -0
- package/dist/style/rule/rule.js +64 -0
- package/dist/style/rule/style.d.ts +3 -3
- package/dist/style/rule/style.js +2 -2
- package/dist/style/rule/supports.d.ts +2 -2
- package/dist/style/rule/supports.js +2 -3
- package/dist/style/sheet.d.ts +1 -1
- package/dist/style/sheet.js +2 -2
- package/package.json +29 -30
- package/dist/node/element/predicate.d.ts +0 -19
- package/dist/node/element/predicate.js +0 -19
- package/dist/node/predicate.d.ts +0 -7
- package/dist/node/predicate.js +0 -7
- package/dist/node/slot.d.ts +0 -29
- package/dist/node/slot.js +0 -41
- package/dist/node/slotable.d.ts +0 -29
- package/dist/node/slotable.js +0 -40
- package/dist/node/traversal.d.ts +0 -2
- package/dist/node/traversal.js +0 -2
- package/dist/style/rule.d.ts +0 -60
- package/dist/style/rule.js +0 -109
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Iterable } from "@siteimprove/alfa-iterable";
|
|
2
|
+
import { Element } from "./element.js";
|
|
3
|
+
import type { Slotable } from "./index.js";
|
|
4
|
+
/** @public */
|
|
5
|
+
export type Slot = Element<"slot">;
|
|
6
|
+
declare module "./element.js" {
|
|
7
|
+
interface Element<N extends string> {
|
|
8
|
+
/**
|
|
9
|
+
* Get the slotables assigned to this slot.
|
|
10
|
+
*
|
|
11
|
+
* {@link https://html.spec.whatwg.org/#dom-slot-assignednodes}
|
|
12
|
+
* {@link https://dom.spec.whatwg.org/#find-slotables}
|
|
13
|
+
*/
|
|
14
|
+
assignedNodes(this: Slot): Iterable<Slotable>;
|
|
15
|
+
/**
|
|
16
|
+
* {@link https://dom.spec.whatwg.org/#slot-name}
|
|
17
|
+
*/
|
|
18
|
+
slotName(this: Slot): string;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=slot.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Iterable } from "@siteimprove/alfa-iterable";
|
|
2
|
+
import { Element } from "./element.js";
|
|
3
|
+
import { Shadow } from "../shadow.js";
|
|
4
|
+
import { Slotable as BaseSlotable } from "./slotable.js";
|
|
5
|
+
Element.prototype.assignedNodes = function* () {
|
|
6
|
+
const root = this.root();
|
|
7
|
+
if (Shadow.isShadow(root)) {
|
|
8
|
+
for (const host of root.host) {
|
|
9
|
+
for (const child of host.children()) {
|
|
10
|
+
if (BaseSlotable.isSlotable(child) &&
|
|
11
|
+
child.assignedSlot().includes(this)) {
|
|
12
|
+
yield child;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
Element.prototype.slotName = function () {
|
|
19
|
+
return this.attribute("name")
|
|
20
|
+
.map((name) => name.value)
|
|
21
|
+
.getOr("");
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=slot.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Option } from "@siteimprove/alfa-option";
|
|
2
|
+
import { BaseNode } from "../node.js";
|
|
3
|
+
import type { Slot } from "./slot.js";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class Slotable<T extends string = string> extends BaseNode<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Get the slot that this slotable is assigned to.
|
|
10
|
+
*
|
|
11
|
+
* {@link https://dom.spec.whatwg.org/#dom-slotable-assignedslot}
|
|
12
|
+
* {@link https://dom.spec.whatwg.org/#find-a-slot}
|
|
13
|
+
*
|
|
14
|
+
* @privateRemarks
|
|
15
|
+
* While the implementation is the same for Element and Text nodes, it uses
|
|
16
|
+
* type guards from Element and therefore cannot really live here without
|
|
17
|
+
* creating circular dependencies.
|
|
18
|
+
*/
|
|
19
|
+
abstract assignedSlot(): Option<Slot>;
|
|
20
|
+
/**
|
|
21
|
+
* {@link https://dom.spec.whatwg.org/#slotable-name}
|
|
22
|
+
*/
|
|
23
|
+
abstract slotableName(): string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare namespace Slotable {
|
|
29
|
+
function isSlotable(value: unknown): value is Slotable;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=slotable.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseNode } from "../node.js";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export class Slotable extends BaseNode {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
(function (Slotable) {
|
|
11
|
+
function isSlotable(value) {
|
|
12
|
+
return value instanceof Slotable;
|
|
13
|
+
}
|
|
14
|
+
Slotable.isSlotable = isSlotable;
|
|
15
|
+
})(Slotable || (Slotable = {}));
|
|
16
|
+
//# sourceMappingURL=slotable.js.map
|
|
@@ -4,13 +4,13 @@ import { Predicate } from "@siteimprove/alfa-predicate";
|
|
|
4
4
|
import { Rectangle } from "@siteimprove/alfa-rectangle";
|
|
5
5
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
6
6
|
import * as json from "@siteimprove/alfa-json";
|
|
7
|
-
import {
|
|
7
|
+
import { BaseNode } from "../node.js";
|
|
8
8
|
import type { Slot } from "./slot.js";
|
|
9
9
|
import { Slotable } from "./slotable.js";
|
|
10
10
|
/**
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
export declare class Text extends
|
|
13
|
+
export declare class Text extends Slotable<"text"> {
|
|
14
14
|
static of(data: string, box?: Option<Rectangle>, device?: Option<Device>, externalId?: string, internalId?: string, extraData?: any): Text;
|
|
15
15
|
static empty(): Text;
|
|
16
16
|
private readonly _data;
|
|
@@ -18,25 +18,26 @@ export declare class Text extends Node<"text"> implements Slotable {
|
|
|
18
18
|
protected constructor(data: string, box: Option<Rectangle>, device: Option<Device>, externalId?: string, internalId?: string, extraData?: any);
|
|
19
19
|
get data(): string;
|
|
20
20
|
assignedSlot(): Option<Slot>;
|
|
21
|
+
slotableName(): string;
|
|
21
22
|
getBoundingBox(device: Device): Option<Rectangle>;
|
|
22
23
|
is(predicate: Predicate<string>): boolean;
|
|
23
24
|
/**
|
|
24
25
|
* @internal
|
|
25
26
|
**/
|
|
26
|
-
protected _internalPath(options?:
|
|
27
|
-
toJSON(options:
|
|
27
|
+
protected _internalPath(options?: BaseNode.Traversal): string;
|
|
28
|
+
toJSON(options: BaseNode.SerializationOptions & {
|
|
28
29
|
verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
|
|
29
30
|
}): Text.MinimalJSON;
|
|
30
|
-
toJSON(options?:
|
|
31
|
+
toJSON(options?: BaseNode.SerializationOptions): Text.JSON;
|
|
31
32
|
toString(): string;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* @public
|
|
35
36
|
*/
|
|
36
37
|
export declare namespace Text {
|
|
37
|
-
interface MinimalJSON extends
|
|
38
|
+
interface MinimalJSON extends BaseNode.JSON<"text"> {
|
|
38
39
|
}
|
|
39
|
-
interface JSON extends
|
|
40
|
+
interface JSON extends BaseNode.JSON<"text"> {
|
|
40
41
|
data: string;
|
|
41
42
|
box: Rectangle.JSON | null;
|
|
42
43
|
}
|
|
@@ -46,9 +47,5 @@ export declare namespace Text {
|
|
|
46
47
|
* @internal
|
|
47
48
|
*/
|
|
48
49
|
function fromText(json: JSON, device?: Device): Trampoline<Text>;
|
|
49
|
-
/**
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
52
|
-
function cloneText(device?: Device): (text: Text) => Trampoline<Text>;
|
|
53
50
|
}
|
|
54
51
|
//# sourceMappingURL=text.d.ts.map
|
|
@@ -4,12 +4,13 @@ import { Predicate } from "@siteimprove/alfa-predicate";
|
|
|
4
4
|
import { Rectangle } from "@siteimprove/alfa-rectangle";
|
|
5
5
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
6
6
|
import * as json from "@siteimprove/alfa-json";
|
|
7
|
-
import {
|
|
7
|
+
import { BaseNode } from "../node.js";
|
|
8
|
+
import { Element } from "./element.js";
|
|
8
9
|
import { Slotable } from "./slotable.js";
|
|
9
10
|
/**
|
|
10
11
|
* @public
|
|
11
12
|
*/
|
|
12
|
-
export class Text extends
|
|
13
|
+
export class Text extends Slotable {
|
|
13
14
|
static of(data, box = None, device = None, externalId, internalId, extraData) {
|
|
14
15
|
return new Text(data, box, device, externalId, internalId, extraData);
|
|
15
16
|
}
|
|
@@ -27,7 +28,16 @@ export class Text extends Node {
|
|
|
27
28
|
return this._data;
|
|
28
29
|
}
|
|
29
30
|
assignedSlot() {
|
|
30
|
-
|
|
31
|
+
const name = this.slotableName();
|
|
32
|
+
return this.parent()
|
|
33
|
+
.filter(Element.isElement)
|
|
34
|
+
.flatMap((parent) => parent.shadow.flatMap((shadow) => shadow
|
|
35
|
+
.descendants()
|
|
36
|
+
.filter(Element.isSlot)
|
|
37
|
+
.find((slot) => slot.slotName() === name)));
|
|
38
|
+
}
|
|
39
|
+
slotableName() {
|
|
40
|
+
return "";
|
|
31
41
|
}
|
|
32
42
|
getBoundingBox(device) {
|
|
33
43
|
return this._boxes.get(device);
|
|
@@ -95,12 +105,5 @@ export class Text extends Node {
|
|
|
95
105
|
return Trampoline.done(Text.of(json.data, Option.from(json.box).map(Rectangle.from), Option.from(device), json.externalId, undefined, json.internalId));
|
|
96
106
|
}
|
|
97
107
|
Text.fromText = fromText;
|
|
98
|
-
/**
|
|
99
|
-
* @internal
|
|
100
|
-
*/
|
|
101
|
-
function cloneText(device) {
|
|
102
|
-
return (text) => Trampoline.done(Text.of(text.data, Option.from(device).flatMap((d) => text.getBoundingBox(d)), Option.from(device), text.externalId, text.extraData, text.internalId));
|
|
103
|
-
}
|
|
104
|
-
Text.cloneText = cloneText;
|
|
105
108
|
})(Text || (Text = {}));
|
|
106
109
|
//# sourceMappingURL=text.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Sequence } from "@siteimprove/alfa-sequence";
|
|
2
|
-
import { Node } from "
|
|
2
|
+
import type { Node } from "../index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get content between two nodes. The relative order of the nodes is unknown.
|
|
5
5
|
* Options let it choose whether the first or second node (in tree order)
|
|
@@ -15,7 +15,7 @@ import { Node } from "../../index.js";
|
|
|
15
15
|
*
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
export declare function getNodesBetween(node1: Node, node2: Node, includeOptions?: Options
|
|
18
|
+
export declare function getNodesBetween(defaultTreeOptions: Node.Traversal): (node1: Node, node2: Node, includeOptions?: Options) => Sequence<Node>;
|
|
19
19
|
type Options = {
|
|
20
20
|
includeFirst: boolean;
|
|
21
21
|
includeSecond: boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
2
|
import { Sequence } from "@siteimprove/alfa-sequence";
|
|
3
|
-
import { Node } from "../../index.js";
|
|
4
3
|
import { lowestCommonAncestor } from "./lowest-common-ancestor.js";
|
|
5
4
|
const { equals, or } = Predicate;
|
|
6
5
|
/**
|
|
@@ -18,41 +17,43 @@ const { equals, or } = Predicate;
|
|
|
18
17
|
*
|
|
19
18
|
* @public
|
|
20
19
|
*/
|
|
21
|
-
export function getNodesBetween(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
export function getNodesBetween(defaultTreeOptions) {
|
|
21
|
+
return function getNodes(node1, node2, includeOptions = { includeFirst: false, includeSecond: false }, treeOptions = defaultTreeOptions) {
|
|
22
|
+
let between = getNodesInclusivelyBetween(node1, node2, treeOptions);
|
|
23
|
+
// If somehow there is nothing between them, escape now
|
|
24
|
+
if (between.isEmpty()) {
|
|
25
|
+
return between;
|
|
26
|
+
}
|
|
27
|
+
// Do we keep the first node or skip its subtree?
|
|
28
|
+
if (!includeOptions.includeFirst) {
|
|
29
|
+
// By previous test, between is not empty
|
|
30
|
+
const first = between.first().getUnsafe();
|
|
31
|
+
// The 'first node after the subtree rooted at first' is the next sibling
|
|
32
|
+
// of the closest ancestor having one.
|
|
33
|
+
between = first
|
|
34
|
+
// Closest ancestor with a next sibling.
|
|
35
|
+
.closest((ancestor) => ancestor.next(treeOptions).isSome(), treeOptions)
|
|
36
|
+
// Get that sibling.
|
|
37
|
+
.flatMap((node) => node.next(treeOptions))
|
|
38
|
+
// Skip everything until next.
|
|
39
|
+
.map((next) => between.skipUntil((node) => node.equals(next)))
|
|
40
|
+
// If nothing after the subtree at first, just escape.
|
|
41
|
+
.getOrElse(Sequence.empty);
|
|
42
|
+
}
|
|
43
|
+
// Do we keep the second node or remove it?
|
|
44
|
+
between =
|
|
45
|
+
includeOptions.includeSecond || between.isEmpty()
|
|
46
|
+
? between
|
|
47
|
+
: between.skipLast(1);
|
|
25
48
|
return between;
|
|
26
|
-
}
|
|
27
|
-
// Do we keep the first node or skip its subtree?
|
|
28
|
-
if (!includeOptions.includeFirst) {
|
|
29
|
-
// By previous test, between is not empty
|
|
30
|
-
const first = between.first().getUnsafe();
|
|
31
|
-
// The 'first node after the subtree rooted at first' is the next sibling
|
|
32
|
-
// of the closest ancestor having one.
|
|
33
|
-
between = first
|
|
34
|
-
// Closest ancestor with a next sibling.
|
|
35
|
-
.closest((ancestor) => ancestor.next(treeOptions).isSome(), treeOptions)
|
|
36
|
-
// Get that sibling.
|
|
37
|
-
.flatMap((node) => node.next(treeOptions))
|
|
38
|
-
// Skip everything until next.
|
|
39
|
-
.map((next) => between.skipUntil((node) => node.equals(next)))
|
|
40
|
-
// If nothing after the subtree at first, just escape.
|
|
41
|
-
.getOrElse(Sequence.empty);
|
|
42
|
-
}
|
|
43
|
-
// Do we keep the second node or remove it?
|
|
44
|
-
between =
|
|
45
|
-
includeOptions.includeSecond || between.isEmpty()
|
|
46
|
-
? between
|
|
47
|
-
: between.skipLast(1);
|
|
48
|
-
return between;
|
|
49
|
+
};
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Get all nodes between node1 and node2, included.
|
|
52
53
|
*/
|
|
53
54
|
function getNodesInclusivelyBetween(node1, node2, treeOptions) {
|
|
54
55
|
const isFrontier = or(equals(node1), equals(node2));
|
|
55
|
-
return lowestCommonAncestor(node1, node2
|
|
56
|
+
return lowestCommonAncestor(treeOptions)(node1, node2)
|
|
56
57
|
.map((context) => context
|
|
57
58
|
.inclusiveDescendants(treeOptions)
|
|
58
59
|
.skipUntil(isFrontier)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from "@siteimprove/alfa-option";
|
|
2
|
-
import {
|
|
2
|
+
import type { BaseNode } from "../node.js";
|
|
3
3
|
/**
|
|
4
4
|
* Find the lowest common ancestor of two nodes:
|
|
5
5
|
* * get the ancestors chain of both
|
|
@@ -9,5 +9,5 @@ import { Node } from "../../index.js";
|
|
|
9
9
|
*
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export declare function lowestCommonAncestor(node1:
|
|
12
|
+
export declare function lowestCommonAncestor(defaultTraversal: BaseNode.Traversal): (node1: BaseNode, node2: BaseNode, options?: BaseNode.Traversal) => Option<BaseNode>;
|
|
13
13
|
//# sourceMappingURL=lowest-common-ancestor.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { None, Option } from "@siteimprove/alfa-option";
|
|
2
|
-
import { Node } from "../../index.js";
|
|
3
2
|
/**
|
|
4
3
|
* Find the lowest common ancestor of two nodes:
|
|
5
4
|
* * get the ancestors chain of both
|
|
@@ -9,8 +8,8 @@ import { Node } from "../../index.js";
|
|
|
9
8
|
*
|
|
10
9
|
* @internal
|
|
11
10
|
*/
|
|
12
|
-
export function lowestCommonAncestor(
|
|
13
|
-
return node1
|
|
11
|
+
export function lowestCommonAncestor(defaultTraversal) {
|
|
12
|
+
return (node1, node2, options = defaultTraversal) => node1
|
|
14
13
|
.inclusiveAncestors(options)
|
|
15
14
|
.reverse()
|
|
16
15
|
.zip(node2.inclusiveAncestors(options).reverse())
|
package/dist/node/type.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Option } from "@siteimprove/alfa-option";
|
|
2
2
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
3
3
|
import * as json from "@siteimprove/alfa-json";
|
|
4
|
-
import {
|
|
4
|
+
import { BaseNode } from "./node.js";
|
|
5
5
|
/**
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export declare class Type<N extends string = string> extends
|
|
8
|
+
export declare class Type<N extends string = string> extends BaseNode<"type"> {
|
|
9
9
|
static of<N extends string = string>(name: N, publicId?: Option<string>, systemId?: Option<string>, externalId?: string, internalId?: string, extraData?: any): Type<N>;
|
|
10
10
|
static empty(): Type;
|
|
11
11
|
private readonly _name;
|
|
@@ -15,19 +15,19 @@ export declare class Type<N extends string = string> extends Node<"type"> {
|
|
|
15
15
|
get name(): N;
|
|
16
16
|
get publicId(): Option<string>;
|
|
17
17
|
get systemId(): Option<string>;
|
|
18
|
-
toJSON(options:
|
|
18
|
+
toJSON(options: BaseNode.SerializationOptions & {
|
|
19
19
|
verbosity: json.Serializable.Verbosity.Minimal | json.Serializable.Verbosity.Low;
|
|
20
20
|
}): Type.MinimalJSON;
|
|
21
|
-
toJSON(options?:
|
|
21
|
+
toJSON(options?: BaseNode.SerializationOptions): Type.JSON<N>;
|
|
22
22
|
toString(): string;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
27
|
export declare namespace Type {
|
|
28
|
-
interface MinimalJSON extends
|
|
28
|
+
interface MinimalJSON extends BaseNode.JSON<"type"> {
|
|
29
29
|
}
|
|
30
|
-
interface JSON<N extends string = string> extends
|
|
30
|
+
interface JSON<N extends string = string> extends BaseNode.JSON<"type"> {
|
|
31
31
|
name: N;
|
|
32
32
|
publicId: string | null;
|
|
33
33
|
systemId: string | null;
|
|
@@ -37,9 +37,5 @@ export declare namespace Type {
|
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
39
|
function fromType<N extends string = string>(json: JSON<N>): Trampoline<Type<N>>;
|
|
40
|
-
/**
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
function cloneType<N extends string = string>(type: Type<N>): Trampoline<Type<N>>;
|
|
44
40
|
}
|
|
45
41
|
//# sourceMappingURL=type.d.ts.map
|
package/dist/node/type.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { None, Option } from "@siteimprove/alfa-option";
|
|
2
2
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
3
3
|
import * as json from "@siteimprove/alfa-json";
|
|
4
|
-
import {
|
|
4
|
+
import { BaseNode } from "./node.js";
|
|
5
5
|
/**
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export class Type extends
|
|
8
|
+
export class Type extends BaseNode {
|
|
9
9
|
static of(name, publicId = None, systemId = None, externalId, internalId, extraData) {
|
|
10
10
|
return new Type(name, publicId, systemId, externalId, internalId, extraData);
|
|
11
11
|
}
|
|
@@ -63,12 +63,5 @@ export class Type extends Node {
|
|
|
63
63
|
return Trampoline.done(Type.of(json.name, Option.from(json.publicId), Option.from(json.systemId), json.externalId, json.internalId));
|
|
64
64
|
}
|
|
65
65
|
Type.fromType = fromType;
|
|
66
|
-
/**
|
|
67
|
-
* @internal
|
|
68
|
-
*/
|
|
69
|
-
function cloneType(type) {
|
|
70
|
-
return Trampoline.done(Type.of(type.name, type.publicId, type.systemId, type.externalId, type.internalId));
|
|
71
|
-
}
|
|
72
|
-
Type.cloneType = cloneType;
|
|
73
66
|
})(Type || (Type = {}));
|
|
74
67
|
//# sourceMappingURL=type.js.map
|
|
@@ -2,8 +2,8 @@ import type { Equatable } from "@siteimprove/alfa-equatable";
|
|
|
2
2
|
import type { Serializable } from "@siteimprove/alfa-json";
|
|
3
3
|
import { Option } from "@siteimprove/alfa-option";
|
|
4
4
|
import type * as json from "@siteimprove/alfa-json";
|
|
5
|
-
import type { Element } from "../node/element.js";
|
|
6
|
-
import type { Rule } from "./rule.js";
|
|
5
|
+
import type { Element } from "../node/slotable/element.js";
|
|
6
|
+
import type { Rule } from "./rule/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
2
2
|
import { Block } from "../block.js";
|
|
3
3
|
import type { Declaration } from "../declaration.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BaseRule } from "./rule.js";
|
|
5
5
|
/**
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export declare class FontFaceRule extends
|
|
8
|
+
export declare class FontFaceRule extends BaseRule<"font-face"> {
|
|
9
9
|
static of(declarations: Iterable<Declaration>): FontFaceRule;
|
|
10
10
|
private readonly _style;
|
|
11
11
|
protected constructor(declarations: Array<Declaration>);
|
|
@@ -17,7 +17,7 @@ export declare class FontFaceRule extends Rule<"font-face"> {
|
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
export declare namespace FontFaceRule {
|
|
20
|
-
interface JSON extends
|
|
20
|
+
interface JSON extends BaseRule.JSON<"font-face"> {
|
|
21
21
|
style: Block.JSON | string;
|
|
22
22
|
}
|
|
23
23
|
function isFontFaceRule(value: unknown): value is FontFaceRule;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { String } from "@siteimprove/alfa-string";
|
|
2
2
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
3
3
|
import { Block } from "../block.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BaseRule } from "./rule.js";
|
|
5
5
|
/**
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export class FontFaceRule extends
|
|
8
|
+
export class FontFaceRule extends BaseRule {
|
|
9
9
|
static of(declarations) {
|
|
10
10
|
return new FontFaceRule(Array.from(declarations));
|
|
11
11
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Array } from "@siteimprove/alfa-array";
|
|
2
|
-
import { Rule } from "
|
|
2
|
+
import type { Rule } from "./index.js";
|
|
3
|
+
import { BaseRule } from "./rule.js";
|
|
3
4
|
/**
|
|
4
5
|
* @public
|
|
5
6
|
*/
|
|
6
|
-
export declare abstract class GroupingRule<T extends string = string> extends
|
|
7
|
+
export declare abstract class GroupingRule<T extends string = string> extends BaseRule<T> {
|
|
7
8
|
protected readonly _rules: Array<Rule>;
|
|
8
9
|
protected constructor(type: T, rules: Array<Rule>);
|
|
9
10
|
get rules(): Iterable<Rule>;
|
|
@@ -14,7 +15,7 @@ export declare abstract class GroupingRule<T extends string = string> extends Ru
|
|
|
14
15
|
* @public
|
|
15
16
|
*/
|
|
16
17
|
export declare namespace GroupingRule {
|
|
17
|
-
interface JSON<T extends string = string> extends
|
|
18
|
+
interface JSON<T extends string = string> extends BaseRule.JSON<T> {
|
|
18
19
|
rules: Array<Rule.JSON>;
|
|
19
20
|
}
|
|
20
21
|
function isGroupingRule(value: unknown): value is GroupingRule;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Array } from "@siteimprove/alfa-array";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseRule } from "./rule.js";
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export class GroupingRule extends
|
|
6
|
+
export class GroupingRule extends BaseRule {
|
|
7
7
|
_rules;
|
|
8
8
|
constructor(type, rules) {
|
|
9
9
|
super(type);
|
|
@@ -4,8 +4,8 @@ import { Iterable } from "@siteimprove/alfa-iterable";
|
|
|
4
4
|
import { Option } from "@siteimprove/alfa-option";
|
|
5
5
|
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
6
6
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
7
|
-
import { Rule } from "
|
|
8
|
-
import { Sheet } from "../sheet.js";
|
|
7
|
+
import type { Rule } from "./index.js";
|
|
8
|
+
import type { Sheet } from "../sheet.js";
|
|
9
9
|
import { ConditionRule } from "./condition.js";
|
|
10
10
|
/**
|
|
11
11
|
* @public
|
|
@@ -43,6 +43,6 @@ export declare namespace ImportRule {
|
|
|
43
43
|
/**
|
|
44
44
|
* @internal
|
|
45
45
|
*/
|
|
46
|
-
function fromImportRule(json: JSON): Trampoline<ImportRule>;
|
|
46
|
+
function fromImportRule(json: JSON, fromRule: (json: Rule.JSON) => Trampoline<Rule>, sheetFactory: (rules: Iterable<Rule>) => Sheet): Trampoline<ImportRule>;
|
|
47
47
|
}
|
|
48
48
|
//# sourceMappingURL=import.d.ts.map
|
|
@@ -4,8 +4,6 @@ import { Iterable } from "@siteimprove/alfa-iterable";
|
|
|
4
4
|
import { None, Option } from "@siteimprove/alfa-option";
|
|
5
5
|
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
6
6
|
import { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
7
|
-
import { Rule } from "../rule.js";
|
|
8
|
-
import { Sheet } from "../sheet.js";
|
|
9
7
|
import { ConditionRule } from "./condition.js";
|
|
10
8
|
const { and } = Predicate;
|
|
11
9
|
/**
|
|
@@ -108,8 +106,8 @@ export class ImportRule extends ConditionRule {
|
|
|
108
106
|
/**
|
|
109
107
|
* @internal
|
|
110
108
|
*/
|
|
111
|
-
function fromImportRule(json) {
|
|
112
|
-
return Trampoline.traverse(json.rules,
|
|
109
|
+
function fromImportRule(json, fromRule, sheetFactory) {
|
|
110
|
+
return Trampoline.traverse(json.rules, fromRule).map((rules) => ImportRule.of(json.href, sheetFactory(rules), Option.of(json.condition), Option.from(json.supportText), Option.from(json.layer)));
|
|
113
111
|
}
|
|
114
112
|
ImportRule.fromImportRule = fromImportRule;
|
|
115
113
|
})(ImportRule || (ImportRule = {}));
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Trampoline } from "@siteimprove/alfa-trampoline";
|
|
2
|
+
import type { Sheet } from "../sheet.js";
|
|
3
|
+
import { FontFaceRule } from "./font-face.js";
|
|
4
|
+
import { GroupingRule } from "./grouping.js";
|
|
5
|
+
import { ImportRule } from "./import.js";
|
|
6
|
+
import { KeyframeRule } from "./keyframe.js";
|
|
7
|
+
import { KeyframesRule } from "./keyframes.js";
|
|
8
|
+
import { Layer as LayerRules } from "./layer.js";
|
|
9
|
+
import { MediaRule } from "./media.js";
|
|
10
|
+
import { NamespaceRule } from "./namespace.js";
|
|
11
|
+
import { PageRule } from "./page.js";
|
|
12
|
+
import { StyleRule } from "./style.js";
|
|
13
|
+
import { SupportsRule } from "./supports.js";
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export type Rule = Rule.FontFace | Rule.Grouping | Rule.Import | Rule.Keyframe | Rule.Keyframes | Rule.Layer.Block | Rule.Layer.Statement | Rule.Media | Rule.Namespace | Rule.Page | Rule.Style | Rule.Supports;
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare namespace Rule {
|
|
22
|
+
export import FontFace = FontFaceRule;
|
|
23
|
+
export import Grouping = GroupingRule;
|
|
24
|
+
export import Import = ImportRule;
|
|
25
|
+
export import Keyframe = KeyframeRule;
|
|
26
|
+
export import Keyframes = KeyframesRule;
|
|
27
|
+
namespace Layer {
|
|
28
|
+
export import Block = LayerRules.BlockRule;
|
|
29
|
+
export import Statement = LayerRules.StatementRule;
|
|
30
|
+
}
|
|
31
|
+
export import Media = MediaRule;
|
|
32
|
+
export import Namespace = NamespaceRule;
|
|
33
|
+
export import Page = PageRule;
|
|
34
|
+
export import Style = StyleRule;
|
|
35
|
+
export import Supports = SupportsRule;
|
|
36
|
+
type JSON = FontFace.JSON | Grouping.JSON | Import.JSON | Keyframe.JSON | Keyframes.JSON | Layer.Block.JSON | Layer.Statement.JSON | Media.JSON | Namespace.JSON | Page.JSON | Style.JSON | Supports.JSON;
|
|
37
|
+
const fontFace: typeof FontFace.of, isFontFaceRule: typeof FontFace.isFontFaceRule;
|
|
38
|
+
const importRule: typeof Import.of, isImportRule: typeof Import.isImportRule;
|
|
39
|
+
const keyframe: typeof Keyframe.of, isKeyframeRule: typeof Keyframe.isKeyframeRule;
|
|
40
|
+
const keyframes: typeof Keyframes.of, isKeyframesRule: typeof Keyframes.isKeyframesRule;
|
|
41
|
+
const layerBlock: typeof LayerRules.BlockRule.of, isLayerBlockRule: typeof LayerRules.BlockRule.isLayerBlockRule;
|
|
42
|
+
const layerStatement: typeof LayerRules.StatementRule.of, isLayerStatementRule: typeof LayerRules.StatementRule.isLayerStatementRule;
|
|
43
|
+
const media: typeof Media.of, isMediaRule: typeof Media.isMediaRule;
|
|
44
|
+
const namespace: typeof Namespace.of, isNamespaceRule: typeof Namespace.isNamespaceRule;
|
|
45
|
+
const page: typeof Page.of, isPageRule: typeof Page.isPageRule;
|
|
46
|
+
const style: typeof Style.of, isStyleRule: typeof Style.isStyleRule;
|
|
47
|
+
const supports: typeof Supports.of, isSupportsRule: typeof Supports.isSupportsRule;
|
|
48
|
+
function from(json: FontFace.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): FontFace;
|
|
49
|
+
function from(json: Import.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Import;
|
|
50
|
+
function from(json: Keyframe.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Keyframe;
|
|
51
|
+
function from(json: Keyframes.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Keyframes;
|
|
52
|
+
function from(json: Layer.Block.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Layer.Block;
|
|
53
|
+
function from(json: Layer.Statement.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Layer.Statement;
|
|
54
|
+
function from(json: Media.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Media;
|
|
55
|
+
function from(json: Namespace.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Namespace;
|
|
56
|
+
function from(json: Page.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Page;
|
|
57
|
+
function from(json: Style.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Style;
|
|
58
|
+
function from(json: Supports.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Supports;
|
|
59
|
+
function from(json: Rule.JSON, sheetFactory: (rules: Iterable<Rule>) => Sheet): Rule;
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
function fromRule(sheetFactory: (rules: Iterable<Rule>) => Sheet): (json: Rule.JSON) => Trampoline<Rule>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|