@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.
- package/CHANGELOG.md +291 -0
- package/dist/h.d.ts +37 -0
- package/dist/h.js +214 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/jsx-runtime.d.ts +26 -0
- package/dist/jsx-runtime.js +41 -0
- package/dist/jsx.d.ts +44 -0
- package/dist/jsx.js +45 -0
- package/dist/namespace.d.ts +43 -0
- package/dist/namespace.js +57 -0
- package/dist/native.d.ts +18 -0
- package/dist/native.js +449 -0
- package/dist/node/attribute/predicate/has-name.d.ts +11 -0
- package/dist/node/attribute/predicate/has-name.js +13 -0
- package/dist/node/attribute/predicate.d.ts +2 -0
- package/dist/node/attribute/predicate.js +2 -0
- package/dist/node/attribute.d.ts +90 -0
- package/dist/node/attribute.js +164 -0
- package/dist/node/comment.d.ts +42 -0
- package/dist/node/comment.js +74 -0
- package/dist/node/document.d.ts +59 -0
- package/dist/node/document.js +113 -0
- package/dist/node/element/input-type.d.ts +12 -0
- package/dist/node/element/input-type.js +10 -0
- package/dist/node/element/predicate/has-attribute.d.ts +12 -0
- package/dist/node/element/predicate/has-attribute.js +11 -0
- package/dist/node/element/predicate/has-box.d.ts +9 -0
- package/dist/node/element/predicate/has-box.js +7 -0
- package/dist/node/element/predicate/has-display-size.d.ts +7 -0
- package/dist/node/element/predicate/has-display-size.js +28 -0
- package/dist/node/element/predicate/has-id.d.ts +16 -0
- package/dist/node/element/predicate/has-id.js +17 -0
- package/dist/node/element/predicate/has-input-type.d.ts +12 -0
- package/dist/node/element/predicate/has-input-type.js +17 -0
- package/dist/node/element/predicate/has-name.d.ts +11 -0
- package/dist/node/element/predicate/has-name.js +13 -0
- package/dist/node/element/predicate/has-namespace.d.ts +12 -0
- package/dist/node/element/predicate/has-namespace.js +13 -0
- package/dist/node/element/predicate/has-tab-index.d.ts +12 -0
- package/dist/node/element/predicate/has-tab-index.js +11 -0
- package/dist/node/element/predicate/has-unique-id.d.ts +7 -0
- package/dist/node/element/predicate/has-unique-id.js +31 -0
- package/dist/node/element/predicate/is-actually-disabled.d.ts +8 -0
- package/dist/node/element/predicate/is-actually-disabled.js +47 -0
- package/dist/node/element/predicate/is-browsing-context-container.d.ts +8 -0
- package/dist/node/element/predicate/is-browsing-context-container.js +20 -0
- package/dist/node/element/predicate/is-content.d.ts +10 -0
- package/dist/node/element/predicate/is-content.js +17 -0
- package/dist/node/element/predicate/is-document-element.d.ts +6 -0
- package/dist/node/element/predicate/is-document-element.js +13 -0
- package/dist/node/element/predicate/is-draggable.d.ts +8 -0
- package/dist/node/element/predicate/is-draggable.js +28 -0
- package/dist/node/element/predicate/is-editing-host.d.ts +8 -0
- package/dist/node/element/predicate/is-editing-host.js +20 -0
- package/dist/node/element/predicate/is-fallback.d.ts +15 -0
- package/dist/node/element/predicate/is-fallback.js +28 -0
- package/dist/node/element/predicate/is-replaced.d.ts +8 -0
- package/dist/node/element/predicate/is-replaced.js +17 -0
- package/dist/node/element/predicate/is-scoped-to.d.ts +7 -0
- package/dist/node/element/predicate/is-scoped-to.js +11 -0
- package/dist/node/element/predicate/is-suggested-focusable.d.ts +14 -0
- package/dist/node/element/predicate/is-suggested-focusable.js +47 -0
- package/dist/node/element/predicate.d.ts +20 -0
- package/dist/node/element/predicate.js +20 -0
- package/dist/node/element.d.ts +122 -0
- package/dist/node/element.js +330 -0
- package/dist/node/fragment.d.ts +38 -0
- package/dist/node/fragment.js +68 -0
- package/dist/node/predicate/has-child.d.ts +7 -0
- package/dist/node/predicate/has-child.js +8 -0
- package/dist/node/predicate/has-descendant.d.ts +7 -0
- package/dist/node/predicate/has-descendant.js +8 -0
- package/dist/node/predicate/has-inclusive-descendant.d.ts +7 -0
- package/dist/node/predicate/has-inclusive-descendant.js +8 -0
- package/dist/node/predicate/has-text-content.d.ts +7 -0
- package/dist/node/predicate/has-text-content.js +12 -0
- package/dist/node/predicate/is-root.d.ts +7 -0
- package/dist/node/predicate/is-root.js +7 -0
- package/dist/node/predicate.d.ts +6 -0
- package/dist/node/predicate.js +6 -0
- package/dist/node/query/element-descendants.d.ts +8 -0
- package/dist/node/query/element-descendants.js +17 -0
- package/dist/node/query/element-id-map.d.ts +14 -0
- package/dist/node/query/element-id-map.js +30 -0
- package/dist/node/query/inclusive-element-descendants.d.ts +8 -0
- package/dist/node/query/inclusive-element-descendants.js +10 -0
- package/dist/node/query/index.d.ts +12 -0
- package/dist/node/query/index.js +13 -0
- package/dist/node/shadow.d.ts +66 -0
- package/dist/node/shadow.js +128 -0
- package/dist/node/slot.d.ts +29 -0
- package/dist/node/slot.js +41 -0
- package/dist/node/slotable.d.ts +29 -0
- package/dist/node/slotable.js +40 -0
- package/dist/node/text.d.ts +46 -0
- package/dist/node/text.js +83 -0
- package/dist/node/traversal/get-nodes-between.d.ts +24 -0
- package/dist/node/traversal/get-nodes-between.js +62 -0
- package/dist/node/traversal/lowest-common-ancestor.d.ts +13 -0
- package/dist/node/traversal/lowest-common-ancestor.js +19 -0
- package/dist/node/traversal.d.ts +2 -0
- package/dist/node/traversal.js +2 -0
- package/dist/node/type.d.ts +45 -0
- package/dist/node/type.js +74 -0
- package/dist/node.d.ts +263 -0
- package/dist/node.js +325 -0
- package/dist/style/block.d.ts +30 -0
- package/dist/style/block.js +63 -0
- package/dist/style/declaration.d.ts +65 -0
- package/dist/style/declaration.js +103 -0
- package/dist/style/rule/condition.d.ts +21 -0
- package/dist/style/rule/condition.js +30 -0
- package/dist/style/rule/font-face.d.ts +29 -0
- package/dist/style/rule/font-face.js +47 -0
- package/dist/style/rule/grouping.d.ts +22 -0
- package/dist/style/rule/grouping.js +34 -0
- package/dist/style/rule/import.d.ts +47 -0
- package/dist/style/rule/import.js +114 -0
- package/dist/style/rule/keyframe.d.ts +32 -0
- package/dist/style/rule/keyframe.js +53 -0
- package/dist/style/rule/keyframes.d.ts +28 -0
- package/dist/style/rule/keyframes.js +49 -0
- package/dist/style/rule/layer.d.ts +61 -0
- package/dist/style/rule/layer.js +106 -0
- package/dist/style/rule/media.d.ts +32 -0
- package/dist/style/rule/media.js +54 -0
- package/dist/style/rule/namespace.d.ts +31 -0
- package/dist/style/rule/namespace.js +52 -0
- package/dist/style/rule/page.d.ts +32 -0
- package/dist/style/rule/page.js +53 -0
- package/dist/style/rule/style.d.ts +35 -0
- package/dist/style/rule/style.js +62 -0
- package/dist/style/rule/supports.d.ts +32 -0
- package/dist/style/rule/supports.js +56 -0
- package/dist/style/rule.d.ts +60 -0
- package/dist/style/rule.js +109 -0
- package/dist/style/sheet.d.ts +37 -0
- package/dist/style/sheet.js +66 -0
- package/package.json +69 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Iterable } from "@siteimprove/alfa-iterable";
|
|
2
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
3
|
+
const { equals } = Predicate;
|
|
4
|
+
export function hasId(idOrPredicate = () => true, ...ids) {
|
|
5
|
+
let predicate;
|
|
6
|
+
if (typeof idOrPredicate === "function") {
|
|
7
|
+
predicate = idOrPredicate;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof idOrPredicate === "string") {
|
|
10
|
+
predicate = equals(idOrPredicate, ...ids);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
predicate = (value) => Iterable.includes(ids, value);
|
|
14
|
+
}
|
|
15
|
+
return (element) => element.id.some(predicate);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=has-id.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import type { Element } from "../../element.js";
|
|
3
|
+
import { type InputType } from "../input-type.js";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasInputType(predicate: Predicate<InputType>): Predicate<Element>;
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasInputType(inputType: InputType, ...rest: Array<InputType>): Predicate<Element>;
|
|
12
|
+
//# sourceMappingURL=has-input-type.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import { Refinement } from "@siteimprove/alfa-refinement";
|
|
3
|
+
import { inputType } from "../input-type.js";
|
|
4
|
+
import { hasName } from "./has-name.js";
|
|
5
|
+
const { equals, test } = Predicate;
|
|
6
|
+
const { and } = Refinement;
|
|
7
|
+
export function hasInputType(inputTypeOrPredicate, ...inputTypes) {
|
|
8
|
+
let predicate;
|
|
9
|
+
if (typeof inputTypeOrPredicate === "function") {
|
|
10
|
+
predicate = inputTypeOrPredicate;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
predicate = equals(inputTypeOrPredicate, ...inputTypes);
|
|
14
|
+
}
|
|
15
|
+
return and(hasName("input"), (element) => test(predicate, inputType(element)));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=has-input-type.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Refinement } from "@siteimprove/alfa-refinement";
|
|
2
|
+
import type { Element } from "../../element.js";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare function hasName<N extends string = string>(predicate: Refinement<string, N>): Refinement<Element, Element<N>>;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare function hasName<N extends string = string>(name: N, ...rest: Array<N>): Refinement<Element, Element<N>>;
|
|
11
|
+
//# sourceMappingURL=has-name.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
const { equals } = Predicate;
|
|
3
|
+
export function hasName(nameOrPredicate, ...names) {
|
|
4
|
+
let predicate;
|
|
5
|
+
if (typeof nameOrPredicate === "function") {
|
|
6
|
+
predicate = nameOrPredicate;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
predicate = equals(nameOrPredicate, ...names);
|
|
10
|
+
}
|
|
11
|
+
return (element) => predicate(element.name);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=has-name.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import type { Namespace } from "../../../namespace.js";
|
|
3
|
+
import type { Element } from "../../element.js";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasNamespace(predicate: Predicate<Namespace>): Predicate<Element>;
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasNamespace(namespace: Namespace, ...rest: Array<Namespace>): Predicate<Element>;
|
|
12
|
+
//# sourceMappingURL=has-namespace.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
const { equals } = Predicate;
|
|
3
|
+
export function hasNamespace(namespaceOrPredicate, ...namespaces) {
|
|
4
|
+
let predicate;
|
|
5
|
+
if (typeof namespaceOrPredicate === "function") {
|
|
6
|
+
predicate = namespaceOrPredicate;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
predicate = equals(namespaceOrPredicate, ...namespaces);
|
|
10
|
+
}
|
|
11
|
+
return (element) => element.namespace.some(predicate);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=has-namespace.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Array } from "@siteimprove/alfa-array";
|
|
2
|
+
import type { Predicate } from "@siteimprove/alfa-predicate";
|
|
3
|
+
import type { Element } from "../../element.js";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasTabIndex(predicate?: Predicate<number>): Predicate<Element>;
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function hasTabIndex(value: number, ...rest: Array<number>): Predicate<Element>;
|
|
12
|
+
//# sourceMappingURL=has-tab-index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Array } from "@siteimprove/alfa-array";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export function hasTabIndex(predicateOrNumber = () => true, ...rest) {
|
|
6
|
+
const predicate = typeof predicateOrNumber === "number"
|
|
7
|
+
? (n) => Array.append(rest, predicateOrNumber).includes(n)
|
|
8
|
+
: predicateOrNumber;
|
|
9
|
+
return (element) => element.tabIndex().some(predicate);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=has-tab-index.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Cache } from "@siteimprove/alfa-cache";
|
|
2
|
+
import { Iterable } from "@siteimprove/alfa-iterable";
|
|
3
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
4
|
+
import { Element } from "../../element.js";
|
|
5
|
+
import { hasId } from "./has-id.js";
|
|
6
|
+
const { and } = Predicate;
|
|
7
|
+
const uniques = Cache.empty();
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export const hasUniqueId = and(hasId(), (element) => uniques
|
|
12
|
+
.get(element.root(), () => {
|
|
13
|
+
const counts = new Map();
|
|
14
|
+
for (const node of element.root().descendants()) {
|
|
15
|
+
if (Element.isElement(node) && node.id.isSome()) {
|
|
16
|
+
const id = node.id.get();
|
|
17
|
+
const count = counts.get(id);
|
|
18
|
+
if (count === undefined) {
|
|
19
|
+
counts.set(id, 1);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
counts.set(id, 1 + count);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return new Set(Iterable.map(Iterable.filter(counts, ([, count]) => count === 1), ([id]) => id));
|
|
27
|
+
})
|
|
28
|
+
// The initial hasId in the conjunction guarantee that there is one.
|
|
29
|
+
// Still defaulting to an impossible one.
|
|
30
|
+
.has(element.id.getOr("impossible id due to spaces")));
|
|
31
|
+
//# sourceMappingURL=has-unique-id.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Element } from "../../element.js";
|
|
2
|
+
/**
|
|
3
|
+
* {@link https://html.spec.whatwg.org/multipage#concept-element-disabled}
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function isActuallyDisabled(element: Element): boolean;
|
|
8
|
+
//# sourceMappingURL=is-actually-disabled.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import { Element } from "../../element.js";
|
|
3
|
+
const { equals } = Predicate;
|
|
4
|
+
/**
|
|
5
|
+
* {@link https://html.spec.whatwg.org/multipage#concept-element-disabled}
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export function isActuallyDisabled(element) {
|
|
10
|
+
switch (element.name) {
|
|
11
|
+
// https://html.spec.whatwg.org/multipage#concept-fe-disabled
|
|
12
|
+
case "button":
|
|
13
|
+
case "input":
|
|
14
|
+
case "select":
|
|
15
|
+
case "textarea":
|
|
16
|
+
// https://html.spec.whatwg.org/#attr-optgroup-disabled
|
|
17
|
+
case "optgroup":
|
|
18
|
+
return element.attribute("disabled").isSome();
|
|
19
|
+
// https://html.spec.whatwg.org/multipage#concept-fieldset-disabled
|
|
20
|
+
case "fieldset":
|
|
21
|
+
if (element.attribute("disabled").isSome()) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return element
|
|
25
|
+
.ancestors()
|
|
26
|
+
.filter(Element.isElement)
|
|
27
|
+
.find(Element.hasName("fieldset"))
|
|
28
|
+
.reject(isActuallyDisabled)
|
|
29
|
+
.flatMap((fieldset) => fieldset
|
|
30
|
+
.descendants()
|
|
31
|
+
.filter(Element.isElement)
|
|
32
|
+
.find(Element.hasName("legend")))
|
|
33
|
+
.some((legend) => legend.descendants().some(equals(element)));
|
|
34
|
+
// https://html.spec.whatwg.org/multipage#concept-option-disabled
|
|
35
|
+
case "option":
|
|
36
|
+
if (element.attribute("disabled").isSome()) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return element
|
|
40
|
+
.inclusiveAncestors()
|
|
41
|
+
.filter(Element.isElement)
|
|
42
|
+
.find(Element.hasName("optgroup"))
|
|
43
|
+
.some(isActuallyDisabled);
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=is-actually-disabled.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Element } from "../../element.js";
|
|
2
|
+
/**
|
|
3
|
+
* {@link https://html.spec.whatwg.org/#browsing-context-container}
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function isBrowsingContextContainer(element: Element): boolean;
|
|
8
|
+
//# sourceMappingURL=is-browsing-context-container.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@link https://html.spec.whatwg.org/#browsing-context-container}
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export function isBrowsingContextContainer(element) {
|
|
7
|
+
switch (element.name) {
|
|
8
|
+
// <iframe> elements are _always_ browsing context containers as they will
|
|
9
|
+
// _always_ have a content document, although it might be empty.
|
|
10
|
+
case "iframe":
|
|
11
|
+
return true;
|
|
12
|
+
// <object> elements are only browsing context containers if they have a
|
|
13
|
+
// content document.
|
|
14
|
+
case "object":
|
|
15
|
+
return element.content.isSome();
|
|
16
|
+
default:
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=is-browsing-context-container.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import { Node } from "../../../node.js";
|
|
3
|
+
/**
|
|
4
|
+
* A node is actual content (not just a container) if it has no children,
|
|
5
|
+
* or if it is a replaced element (assumed to be replaced by actual content).
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function isContent(options?: Node.Traversal): Predicate<Node>;
|
|
10
|
+
//# sourceMappingURL=is-content.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import { Refinement } from "@siteimprove/alfa-refinement";
|
|
3
|
+
import { Element } from "../../element.js";
|
|
4
|
+
import { Node } from "../../../node.js";
|
|
5
|
+
import { isReplaced } from "./is-replaced.js";
|
|
6
|
+
const { or } = Predicate;
|
|
7
|
+
const { and } = Refinement;
|
|
8
|
+
/**
|
|
9
|
+
* A node is actual content (not just a container) if it has no children,
|
|
10
|
+
* or if it is a replaced element (assumed to be replaced by actual content).
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export function isContent(options = Node.Traversal.empty) {
|
|
15
|
+
return or((node) => node.children(options).isEmpty(), and(Element.isElement, isReplaced));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=is-content.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Refinement } from "@siteimprove/alfa-refinement";
|
|
2
|
+
import { Element } from "../../element.js";
|
|
3
|
+
import { Namespace } from "../../../namespace.js";
|
|
4
|
+
import { hasName } from "./has-name.js";
|
|
5
|
+
import { hasNamespace } from "./has-namespace.js";
|
|
6
|
+
const { and, test } = Refinement;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export function isDocumentElement(value) {
|
|
11
|
+
return test(and(Element.isElement, and(hasName("html"), hasNamespace(Namespace.HTML))), value);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=is-document-element.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@link https://html.spec.whatwg.org/#dom-draggable}
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export function isDraggable(element) {
|
|
7
|
+
return element
|
|
8
|
+
.attribute("draggable")
|
|
9
|
+
.map((attribute) => attribute.enumerate("true", "false", "auto").getOr("auto"))
|
|
10
|
+
.some((draggable) => {
|
|
11
|
+
switch (draggable) {
|
|
12
|
+
case "true":
|
|
13
|
+
return true;
|
|
14
|
+
case "false":
|
|
15
|
+
return false;
|
|
16
|
+
case "auto":
|
|
17
|
+
switch (element.name) {
|
|
18
|
+
case "img":
|
|
19
|
+
return true;
|
|
20
|
+
case "a":
|
|
21
|
+
return element.attribute("href").isSome();
|
|
22
|
+
default:
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=is-draggable.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@link https://html.spec.whatwg.org/#editing-host}
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export function isEditingHost(element) {
|
|
7
|
+
return element
|
|
8
|
+
.attribute("contenteditable")
|
|
9
|
+
.flatMap((attribute) => attribute.enumerate("", "true", "false"))
|
|
10
|
+
.some((contenteditable) => {
|
|
11
|
+
switch (contenteditable) {
|
|
12
|
+
case "":
|
|
13
|
+
case "true":
|
|
14
|
+
return true;
|
|
15
|
+
case "false":
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=is-editing-host.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Node } from "../../../node.js";
|
|
2
|
+
/**
|
|
3
|
+
* Children of <iframe>, <audio>, <video> elements act as fallback content in
|
|
4
|
+
* legacy user agents.
|
|
5
|
+
*
|
|
6
|
+
* <track> and <source> children of audio and video are allowed by the content
|
|
7
|
+
* model of both. Thus, they will be not act as fallback
|
|
8
|
+
*
|
|
9
|
+
* {@link https://html.spec.whatwg.org/multipage/#the-video-element}
|
|
10
|
+
* {@link https://html.spec.whatwg.org/multipage/#the-audio-element}
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare function isFallback(node: Node): boolean;
|
|
15
|
+
//# sourceMappingURL=is-fallback.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import { Refinement } from "@siteimprove/alfa-refinement";
|
|
3
|
+
import { Element } from "../../element.js";
|
|
4
|
+
import { hasName } from "./has-name.js";
|
|
5
|
+
const { not, or, test } = Predicate;
|
|
6
|
+
const { and } = Refinement;
|
|
7
|
+
/**
|
|
8
|
+
* Children of <iframe>, <audio>, <video> elements act as fallback content in
|
|
9
|
+
* legacy user agents.
|
|
10
|
+
*
|
|
11
|
+
* <track> and <source> children of audio and video are allowed by the content
|
|
12
|
+
* model of both. Thus, they will be not act as fallback
|
|
13
|
+
*
|
|
14
|
+
* {@link https://html.spec.whatwg.org/multipage/#the-video-element}
|
|
15
|
+
* {@link https://html.spec.whatwg.org/multipage/#the-audio-element}
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export function isFallback(node) {
|
|
20
|
+
return test(or(hasParentName("iframe"), and(hasParentName("audio", "video"), not(and(Element.isElement, hasName("track", "source"))))), node);
|
|
21
|
+
}
|
|
22
|
+
function hasParentName(name, ...names) {
|
|
23
|
+
return (node) => node
|
|
24
|
+
.parent()
|
|
25
|
+
.filter(Element.isElement)
|
|
26
|
+
.some(hasName(name, ...names));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=is-fallback.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Element } from "../../element.js";
|
|
2
|
+
/**
|
|
3
|
+
* {@link https://html.spec.whatwg.org/#replaced-elements}
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function isReplaced(element: Element): element is Element<"audio" | "canvas" | "embed" | "iframe" | "img" | "input" | "object" | "video">;
|
|
8
|
+
//# sourceMappingURL=is-replaced.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Refinement } from "@siteimprove/alfa-refinement";
|
|
2
|
+
import { hasName } from "./has-name.js";
|
|
3
|
+
const { test } = Refinement;
|
|
4
|
+
// For some reason, type inference by "yarn document" seems to depend on
|
|
5
|
+
// machine (?) and returns the list of elements' names in different orders.
|
|
6
|
+
// This notably breaks the CI if "yarn document" there builds a different type
|
|
7
|
+
// than on local machine. Using a function with explicit type seems to stabilize
|
|
8
|
+
// things.
|
|
9
|
+
/**
|
|
10
|
+
* {@link https://html.spec.whatwg.org/#replaced-elements}
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export function isReplaced(element) {
|
|
15
|
+
return test(hasName("audio", "canvas", "embed", "iframe", "img", "input", "object", "video"), element);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=is-replaced.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Predicate } from "@siteimprove/alfa-predicate";
|
|
2
|
+
import { Element } from "../../element.js";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare function isScopedTo(name: string, ...rest: Array<string>): Predicate<Element>;
|
|
7
|
+
//# sourceMappingURL=is-scoped-to.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Element } from "../../element.js";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export function isScopedTo(name, ...rest) {
|
|
6
|
+
return (element) => element
|
|
7
|
+
.ancestors()
|
|
8
|
+
.filter(Element.isElement)
|
|
9
|
+
.some(Element.hasName(name, ...rest));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=is-scoped-to.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Element } from "../../element.js";
|
|
2
|
+
/**
|
|
3
|
+
* {@link https://html.spec.whatwg.org/multipage/#tabindex-value}
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Draggable elements for which the user agent supports drag operations without
|
|
7
|
+
* a pointer device are also suggested focusable. However, we're not aware of
|
|
8
|
+
* any such cases and therefore don't suggest making draggable elements
|
|
9
|
+
* focusable.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function isSuggestedFocusable(element: Element): boolean;
|
|
14
|
+
//# sourceMappingURL=is-suggested-focusable.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Element } from "../../element.js";
|
|
2
|
+
/**
|
|
3
|
+
* {@link https://html.spec.whatwg.org/multipage/#tabindex-value}
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Draggable elements for which the user agent supports drag operations without
|
|
7
|
+
* a pointer device are also suggested focusable. However, we're not aware of
|
|
8
|
+
* any such cases and therefore don't suggest making draggable elements
|
|
9
|
+
* focusable.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export function isSuggestedFocusable(element) {
|
|
14
|
+
switch (element.name) {
|
|
15
|
+
case "a":
|
|
16
|
+
case "link":
|
|
17
|
+
return element.attribute("href").isSome();
|
|
18
|
+
case "input":
|
|
19
|
+
return element
|
|
20
|
+
.attribute("type")
|
|
21
|
+
.flatMap((attribute) => attribute.enumerate("hidden"))
|
|
22
|
+
.isNone();
|
|
23
|
+
case "audio":
|
|
24
|
+
case "video":
|
|
25
|
+
return element.attribute("controls").isSome();
|
|
26
|
+
case "button":
|
|
27
|
+
case "select":
|
|
28
|
+
case "textarea":
|
|
29
|
+
return true;
|
|
30
|
+
case "summary":
|
|
31
|
+
return element
|
|
32
|
+
.parent()
|
|
33
|
+
.filter(Element.isElement)
|
|
34
|
+
.some((parent) => parent.name === "details" &&
|
|
35
|
+
// Checking that element is the first <summary> child of parent.
|
|
36
|
+
parent
|
|
37
|
+
.children()
|
|
38
|
+
.filter(Element.isElement)
|
|
39
|
+
// Switching on element.name does not narrow the type, so we must
|
|
40
|
+
// keep it as Element<string>.
|
|
41
|
+
.find(Element.hasName("summary"))
|
|
42
|
+
.includes(element));
|
|
43
|
+
}
|
|
44
|
+
return (Element.isEditingHost(element) ||
|
|
45
|
+
Element.isBrowsingContextContainer(element));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=is-suggested-focusable.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./predicate/has-attribute.js";
|
|
2
|
+
export * from "./predicate/has-box.js";
|
|
3
|
+
export * from "./predicate/has-display-size.js";
|
|
4
|
+
export * from "./predicate/has-id.js";
|
|
5
|
+
export * from "./predicate/has-input-type.js";
|
|
6
|
+
export * from "./predicate/has-name.js";
|
|
7
|
+
export * from "./predicate/has-namespace.js";
|
|
8
|
+
export * from "./predicate/has-tab-index.js";
|
|
9
|
+
export * from "./predicate/has-unique-id.js";
|
|
10
|
+
export * from "./predicate/is-browsing-context-container.js";
|
|
11
|
+
export * from "./predicate/is-content.js";
|
|
12
|
+
export * from "./predicate/is-actually-disabled.js";
|
|
13
|
+
export * from "./predicate/is-document-element.js";
|
|
14
|
+
export * from "./predicate/is-draggable.js";
|
|
15
|
+
export * from "./predicate/is-editing-host.js";
|
|
16
|
+
export * from "./predicate/is-fallback.js";
|
|
17
|
+
export * from "./predicate/is-scoped-to.js";
|
|
18
|
+
export * from "./predicate/is-suggested-focusable.js";
|
|
19
|
+
export * from "./predicate/is-replaced.js";
|
|
20
|
+
//# sourceMappingURL=predicate.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./predicate/has-attribute.js";
|
|
2
|
+
export * from "./predicate/has-box.js";
|
|
3
|
+
export * from "./predicate/has-display-size.js";
|
|
4
|
+
export * from "./predicate/has-id.js";
|
|
5
|
+
export * from "./predicate/has-input-type.js";
|
|
6
|
+
export * from "./predicate/has-name.js";
|
|
7
|
+
export * from "./predicate/has-namespace.js";
|
|
8
|
+
export * from "./predicate/has-tab-index.js";
|
|
9
|
+
export * from "./predicate/has-unique-id.js";
|
|
10
|
+
export * from "./predicate/is-browsing-context-container.js";
|
|
11
|
+
export * from "./predicate/is-content.js";
|
|
12
|
+
export * from "./predicate/is-actually-disabled.js";
|
|
13
|
+
export * from "./predicate/is-document-element.js";
|
|
14
|
+
export * from "./predicate/is-draggable.js";
|
|
15
|
+
export * from "./predicate/is-editing-host.js";
|
|
16
|
+
export * from "./predicate/is-fallback.js";
|
|
17
|
+
export * from "./predicate/is-scoped-to.js";
|
|
18
|
+
export * from "./predicate/is-suggested-focusable.js";
|
|
19
|
+
export * from "./predicate/is-replaced.js";
|
|
20
|
+
//# sourceMappingURL=predicate.js.map
|