a11y-elements 1.0.2 → 1.1.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/README.md +48 -6
- package/dist/a11y.css +42 -9
- package/dist/browser/all.js +16 -16
- package/dist/browser/{chunk-K7JWBING.js → chunk-2X4DBANG.js} +2 -2
- package/dist/browser/{chunk-MB2GJCKB.js → chunk-3AHPI6C5.js} +2 -2
- package/dist/browser/{chunk-OB2NQV77.js → chunk-3QCORK3F.js} +2 -2
- package/dist/browser/{chunk-7CL7TH7I.js → chunk-4ER4RFUO.js} +2 -2
- package/dist/browser/{chunk-MIBUA46B.js → chunk-6HI2FNGK.js} +2 -2
- package/dist/browser/{chunk-KVUJT6BC.js → chunk-7FIT24VV.js} +56 -7
- package/dist/browser/chunk-7FIT24VV.js.map +1 -0
- package/dist/browser/{chunk-GOYSEJKF.js → chunk-B6V4HID2.js} +2 -2
- package/dist/browser/{chunk-NT7DOWM7.js → chunk-CDDBLEN6.js} +2 -2
- package/dist/browser/{chunk-UKFZ7AT5.js → chunk-F4KVDZS3.js} +12 -1
- package/dist/browser/chunk-F4KVDZS3.js.map +1 -0
- package/dist/browser/{chunk-GA3VPLST.js → chunk-GNAF4MSU.js} +2 -2
- package/dist/browser/{chunk-2HQKZFJV.js → chunk-ONS5T35N.js} +2 -2
- package/dist/browser/{chunk-J5T2K5NR.js → chunk-RGO5EYGG.js} +2 -2
- package/dist/browser/{chunk-OMZFF2KR.js → chunk-RKZNZKLG.js} +47 -22
- package/dist/browser/chunk-RKZNZKLG.js.map +1 -0
- package/dist/browser/{chunk-PO7RAUEO.js → chunk-TU4BZYED.js} +6 -4
- package/dist/browser/chunk-TU4BZYED.js.map +1 -0
- package/dist/browser/chunk-WKWX3MMT.js +233 -0
- package/dist/browser/chunk-WKWX3MMT.js.map +1 -0
- package/dist/browser/{chunk-YQ2VLQAY.js → chunk-YYYJ6D77.js} +15 -1
- package/dist/browser/chunk-YYYJ6D77.js.map +1 -0
- package/dist/browser/components/avatar/define.js +2 -2
- package/dist/browser/components/progress/define.js +2 -2
- package/dist/browser/components/skeleton/define.js +2 -2
- package/dist/browser/components/spinner/define.js +2 -2
- package/dist/browser/overlays/blocking-loader/define.js +3 -3
- package/dist/browser/overlays/context-menu/define.js +3 -3
- package/dist/browser/overlays/dropdown/define.js +3 -3
- package/dist/browser/overlays/modal/define.js +2 -2
- package/dist/browser/overlays/notification-banner/define.js +3 -3
- package/dist/browser/overlays/popover/define.js +2 -2
- package/dist/browser/overlays/snackbar/define.js +3 -3
- package/dist/browser/overlays/tooltip/define.js +2 -2
- package/dist/core/input-modality.d.ts +21 -0
- package/dist/core/input-modality.js +56 -0
- package/dist/core/input-modality.js.map +1 -0
- package/dist/core/sanitize.d.ts +7 -2
- package/dist/core/sanitize.js +14 -5
- package/dist/core/sanitize.js.map +1 -1
- package/dist/core/template.d.ts +11 -2
- package/dist/core/template.js +28 -8
- package/dist/core/template.js.map +1 -1
- package/dist/core/trusted-types.d.ts +34 -0
- package/dist/core/trusted-types.js +78 -0
- package/dist/core/trusted-types.js.map +1 -0
- package/dist/overlays/core/a11y-anchored-overlay-element.d.ts +4 -0
- package/dist/overlays/core/a11y-anchored-overlay-element.js +14 -0
- package/dist/overlays/core/a11y-anchored-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-passive-overlay-element.d.ts +9 -0
- package/dist/overlays/core/a11y-passive-overlay-element.js +14 -0
- package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
- package/dist/overlays/notification-banner/notification-banner.element.d.ts +7 -1
- package/dist/overlays/notification-banner/notification-banner.element.js +9 -1
- package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
- package/dist/overlays/snackbar/snackbar.element.d.ts +20 -7
- package/dist/overlays/snackbar/snackbar.element.js +55 -20
- package/dist/overlays/snackbar/snackbar.element.js.map +1 -1
- package/dist/overlays/tooltip/tooltip.element.d.ts +32 -8
- package/dist/overlays/tooltip/tooltip.element.js +112 -18
- package/dist/overlays/tooltip/tooltip.element.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/chunk-KVUJT6BC.js.map +0 -1
- package/dist/browser/chunk-OMZFF2KR.js.map +0 -1
- package/dist/browser/chunk-PMGHD553.js +0 -124
- package/dist/browser/chunk-PMGHD553.js.map +0 -1
- package/dist/browser/chunk-PO7RAUEO.js.map +0 -1
- package/dist/browser/chunk-UKFZ7AT5.js.map +0 -1
- package/dist/browser/chunk-YQ2VLQAY.js.map +0 -1
- /package/dist/browser/{chunk-K7JWBING.js.map → chunk-2X4DBANG.js.map} +0 -0
- /package/dist/browser/{chunk-MB2GJCKB.js.map → chunk-3AHPI6C5.js.map} +0 -0
- /package/dist/browser/{chunk-OB2NQV77.js.map → chunk-3QCORK3F.js.map} +0 -0
- /package/dist/browser/{chunk-7CL7TH7I.js.map → chunk-4ER4RFUO.js.map} +0 -0
- /package/dist/browser/{chunk-MIBUA46B.js.map → chunk-6HI2FNGK.js.map} +0 -0
- /package/dist/browser/{chunk-GOYSEJKF.js.map → chunk-B6V4HID2.js.map} +0 -0
- /package/dist/browser/{chunk-NT7DOWM7.js.map → chunk-CDDBLEN6.js.map} +0 -0
- /package/dist/browser/{chunk-GA3VPLST.js.map → chunk-GNAF4MSU.js.map} +0 -0
- /package/dist/browser/{chunk-2HQKZFJV.js.map → chunk-ONS5T35N.js.map} +0 -0
- /package/dist/browser/{chunk-J5T2K5NR.js.map → chunk-RGO5EYGG.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/overlays/core/a11y-passive-overlay-element.ts"],"sourcesContent":["import { A11yElement } from '../../core/a11y-element.js';\nimport { forgetPortalOrigin, recordPortalOrigin } from '../../core/overlay-registry.js';\nimport type { Content } from '../../core/dom.js';\nimport { doc } from '../../core/safe-dom.js';\n\nconst DEFAULT_MAX_STACK = 3;\n/** setTimeout's limit: longer (or `Infinity`) delays overflow to 0 and fire at once. */\nconst MAX_TIMEOUT_MS = 2_147_483_647;\n\nexport type PassiveOverlayPosition = 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport const PASSIVE_OVERLAY_POSITIONS: readonly PassiveOverlayPosition[] = ['top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right'];\n\nexport interface PassiveOverlayItem {\n /** Text, nodes, or markup from `raw()`/`trustedRaw()`. */\n message: Content;\n position?: PassiveOverlayPosition;\n duration?: number;\n actionText?: string;\n onAction?: () => void;\n}\n\n/**\n * Base for \"region\" overlays (snackbar, notification-banner) that don't fit\n * the single open/close model `A11yOverlayElement` covers — a passive region\n * is a persistent live-region container the consumer places once in their\n * HTML, and items are shown/dismissed inside it continuously via `enqueue()`\n * (bounded-concurrency FIFO: at most `max-stack` items — default 3 — shown\n * at once, the rest queued), not toggled as a whole.\n *\n * Items only show while the region is in the document: one enqueued while\n * it's detached waits in the queue. When the region is removed (and not\n * just moved: the check runs a microtask later), every pending auto-dismiss\n * timer is cancelled and `_onRemoved()` runs, so nothing keeps firing for a\n * page that's gone.\n */\nexport abstract class A11yPassiveOverlayElement<TItem extends PassiveOverlayItem = PassiveOverlayItem> extends A11yElement {\n static get observedAttributes(): string[] {\n return ['max-stack'];\n }\n\n protected _queue: TItem[] = [];\n protected _activeCount = 0;\n /** Cancel functions of every running `_autoDismiss()` countdown. */\n private _autoDismissCancels = new Set<() => void>();\n\n override connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n const origin = this.parentNode;\n if (origin !== doc.body) {\n doc.body.appendChild(this);\n // Recorded only now: that move ran a nested disconnect, which forgets the origin.\n if (origin instanceof Element) recordPortalOrigin(this, origin);\n }\n this.setAttribute('aria-live', 'polite');\n this.setAttribute('aria-atomic', 'false');\n this.setAttribute('aria-relevant', 'additions removals');\n this.classList.add('a11y-passive-overlay-region');\n }\n\n override disconnectedCallback(): void {\n forgetPortalOrigin(this);\n super.disconnectedCallback();\n // A move (including our own portal to <body> above) disconnects and\n // reconnects synchronously; only tear down if we're still out afterwards.\n queueMicrotask(() => {\n if (!this.isConnected) this._onRemoved();\n });\n }\n\n /**\n * Runs once the region has been removed from the document (not just moved).\n * The base cancels every pending auto-dismiss timer; subclasses may also\n * drop their items.\n */\n protected _onRemoved(): void {\n this._cancelAutoDismissTimers();\n }\n\n /** Stops every pending `_autoDismiss()` countdown without dismissing anything. */\n protected _cancelAutoDismissTimers(): void {\n for (const cancel of Array.from(this._autoDismissCancels)) cancel();\n }\n\n /** Never re-renders (that would wipe the item containers) — a raised `max-stack` just shows queued items. */\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n if (name === 'max-stack') this._drainQueue();\n }\n\n /** How many items may show at once (`max-stack` attribute, default 3); the rest wait in a FIFO queue. */\n get maxStack(): number {\n return Math.max(1, Math.floor(this.numberAttr('max-stack', DEFAULT_MAX_STACK)));\n }\n\n set maxStack(n: number) {\n this.setAttribute('max-stack', String(Math.max(1, n)));\n }\n\n /** Alias for `el.maxStack = n`. */\n setMaxStack(n: number): void {\n this.maxStack = n;\n }\n\n protected enqueue(item: TItem): void {\n this._queue.push(item);\n this._drainQueue();\n }\n\n protected _onItemDismissed(): void {\n this._activeCount--;\n this._drainQueue();\n }\n\n /** Shows queued items up to `maxStack` — only while connected (subclasses call this once their containers exist). */\n protected _drainQueue(): void {\n if (!this.isConnected) return;\n while (this._queue.length > 0 && this._activeCount < this.maxStack) {\n const next = this._queue.shift()!;\n this._activeCount++;\n this._showItem(next);\n }\n }\n\n protected abstract _showItem(item: TItem): void;\n\n /**\n * The default position set in CSS through `property` (e.g.\n * `:root { --a11y-snackbar-position: top-right; }`), read when an item is\n * shown, or `undefined` when it's unset or not one of `allowed`. Quotes and\n * surrounding spaces are ignored. Also `undefined` without\n * `getComputedStyle` (SSR DOMs).\n */\n protected _cssPosition<P extends PassiveOverlayPosition>(property: string, allowed: readonly P[]): P | undefined {\n if (typeof getComputedStyle !== 'function') return undefined;\n const value = getComputedStyle(this).getPropertyValue(property).trim().replace(/^(['\"])(.*)\\1$/, '$2').trim();\n return (allowed as readonly string[]).includes(value) ? (value as P) : undefined;\n }\n\n /**\n * Removes `element` and calls `onDone` after `duration`ms of it being\n * *unattended*: the countdown pauses while the pointer is over the item or\n * focus is inside it (e.g. on its action button), and resumes with the\n * remaining time once both leave (WCAG 2.2.1 — a user reading or reaching\n * for a toast mustn't have it vanish under them). Returns a function that\n * cancels the auto-dismiss entirely.\n */\n protected _autoDismiss(element: HTMLElement, duration: number, onDone: () => void): () => void {\n let remaining = duration;\n let startedAt = 0;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let hovered = false;\n let focused = false;\n\n const run = (): void => {\n if (remaining > MAX_TIMEOUT_MS) return; // `Infinity` or longer than a timer can wait: never auto-dismiss\n startedAt = Date.now();\n timer = setTimeout(() => {\n cancel();\n element.remove();\n onDone();\n }, remaining);\n };\n const pause = (): void => {\n if (!timer) return;\n clearTimeout(timer);\n timer = null;\n remaining = Math.max(0, remaining - (Date.now() - startedAt));\n };\n const refresh = (): void => {\n if (hovered || focused) pause();\n else if (!timer) run();\n };\n const onEnter = (): void => { hovered = true; refresh(); };\n const onLeave = (): void => { hovered = false; refresh(); };\n const onFocusIn = (): void => { focused = true; refresh(); };\n const onFocusOut = (e: FocusEvent): void => {\n if (element.contains(e.relatedTarget as Node | null)) return;\n focused = false;\n refresh();\n };\n const cancel = (): void => {\n this._autoDismissCancels.delete(cancel);\n if (timer) clearTimeout(timer);\n timer = null;\n element.removeEventListener('mouseenter', onEnter);\n element.removeEventListener('mouseleave', onLeave);\n element.removeEventListener('focusin', onFocusIn);\n element.removeEventListener('focusout', onFocusOut);\n };\n\n element.addEventListener('mouseenter', onEnter);\n element.addEventListener('mouseleave', onLeave);\n element.addEventListener('focusin', onFocusIn);\n element.addEventListener('focusout', onFocusOut);\n this._autoDismissCancels.add(cancel);\n run();\n return cancel;\n }\n\n /** Unused — items are appended/removed directly by `_showItem`, never generated from a template. */\n protected override render(): null {\n return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
dismissAllOverlays,
|
|
8
8
|
removeOverlaysWithin
|
|
9
9
|
} from "../../chunk-H25W66MH.js";
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-CDDBLEN6.js";
|
|
11
|
+
import "../../chunk-7FIT24VV.js";
|
|
12
12
|
import {
|
|
13
13
|
resetStrings,
|
|
14
14
|
setStrings
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ContextMenuElement
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-B6V4HID2.js";
|
|
4
|
+
import "../../chunk-RGO5EYGG.js";
|
|
5
|
+
import "../../chunk-F4KVDZS3.js";
|
|
6
6
|
import "../../chunk-MNWKDM3I.js";
|
|
7
7
|
import "../../chunk-IJ6JK2XW.js";
|
|
8
8
|
import "../../chunk-FNILKXCO.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DropdownElement
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-2X4DBANG.js";
|
|
4
|
+
import "../../chunk-RGO5EYGG.js";
|
|
5
|
+
import "../../chunk-F4KVDZS3.js";
|
|
6
6
|
import "../../chunk-MNWKDM3I.js";
|
|
7
7
|
import "../../chunk-IJ6JK2XW.js";
|
|
8
8
|
import "../../chunk-FNILKXCO.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ModalElement,
|
|
3
3
|
confirmDialog
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-ONS5T35N.js";
|
|
5
5
|
import "../../chunk-6VUVGT2G.js";
|
|
6
6
|
import "../../chunk-MNWKDM3I.js";
|
|
7
7
|
import "../../chunk-IJ6JK2XW.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
dismissAllOverlays,
|
|
11
11
|
removeOverlaysWithin
|
|
12
12
|
} from "../../chunk-H25W66MH.js";
|
|
13
|
-
import "../../chunk-
|
|
13
|
+
import "../../chunk-7FIT24VV.js";
|
|
14
14
|
import "../../chunk-Q4TMA3P7.js";
|
|
15
15
|
import {
|
|
16
16
|
resetStrings,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NotificationBannerElement,
|
|
3
3
|
showNotificationBanner
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-TU4BZYED.js";
|
|
5
|
+
import "../../chunk-YYYJ6D77.js";
|
|
6
6
|
import {
|
|
7
7
|
dismissAllOverlays,
|
|
8
8
|
removeOverlaysWithin
|
|
9
9
|
} from "../../chunk-H25W66MH.js";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-7FIT24VV.js";
|
|
11
11
|
import {
|
|
12
12
|
resetStrings,
|
|
13
13
|
setStrings
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PopoverElement
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-3AHPI6C5.js";
|
|
4
|
+
import "../../chunk-F4KVDZS3.js";
|
|
5
5
|
import "../../chunk-MNWKDM3I.js";
|
|
6
6
|
import "../../chunk-IJ6JK2XW.js";
|
|
7
7
|
import "../../chunk-FNILKXCO.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SnackbarElement,
|
|
3
3
|
notify
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-RKZNZKLG.js";
|
|
5
|
+
import "../../chunk-YYYJ6D77.js";
|
|
6
6
|
import {
|
|
7
7
|
dismissAllOverlays,
|
|
8
8
|
removeOverlaysWithin
|
|
9
9
|
} from "../../chunk-H25W66MH.js";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-7FIT24VV.js";
|
|
11
11
|
import {
|
|
12
12
|
resetStrings,
|
|
13
13
|
setStrings
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TooltipElement
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-WKWX3MMT.js";
|
|
4
|
+
import "../../chunk-F4KVDZS3.js";
|
|
5
5
|
import "../../chunk-MNWKDM3I.js";
|
|
6
6
|
import "../../chunk-IJ6JK2XW.js";
|
|
7
7
|
import "../../chunk-FNILKXCO.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type InputModality = 'keyboard' | 'pointer';
|
|
2
|
+
/**
|
|
3
|
+
* Starts tracking whether the last input was a keyboard or a pointer, with
|
|
4
|
+
* capture-phase listeners on `document` installed once per page. Keys
|
|
5
|
+
* pressed with Ctrl/Alt/Meta and lone modifier keys don't count (a shortcut
|
|
6
|
+
* or a screenshot isn't keyboard navigation), like the browsers'
|
|
7
|
+
* `:focus-visible` heuristic. A `preventDefault()`ed key still counts: an
|
|
8
|
+
* Escape that closes a modal and sends focus back is keyboard navigation,
|
|
9
|
+
* though Firefox then doesn't match `:focus-visible`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function trackInputModality(): void;
|
|
12
|
+
/** What the user last used, `null` before any input (or before `trackInputModality()`). */
|
|
13
|
+
export declare function lastInputModality(): InputModality | null;
|
|
14
|
+
/**
|
|
15
|
+
* Whether focus on `el` came from the keyboard: from the last input when
|
|
16
|
+
* there was one, else (focus moved by script on load, `autofocus`) from the
|
|
17
|
+
* browser's `:focus-visible`, and `true` where that selector is unsupported.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isKeyboardFocus(el: Element): boolean;
|
|
20
|
+
/** Forgets the last input. Tests only. */
|
|
21
|
+
export declare function resetInputModality(): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { doc } from './safe-dom.js';
|
|
2
|
+
/**
|
|
3
|
+
* Page-wide, on `globalThis` for the same reason as the overlay registry:
|
|
4
|
+
* each standalone browser bundle inlines its own copy of this module, and
|
|
5
|
+
* they must agree on what the user last did.
|
|
6
|
+
*/
|
|
7
|
+
const STATE_KEY = Symbol.for('a11y-elements/input-modality');
|
|
8
|
+
const store = globalThis;
|
|
9
|
+
const state = (store[STATE_KEY] ??= { last: null, listening: false });
|
|
10
|
+
const MODIFIER_KEYS = new Set(['Shift', 'Control', 'Alt', 'Meta', 'AltGraph', 'CapsLock', 'Fn']);
|
|
11
|
+
/**
|
|
12
|
+
* Starts tracking whether the last input was a keyboard or a pointer, with
|
|
13
|
+
* capture-phase listeners on `document` installed once per page. Keys
|
|
14
|
+
* pressed with Ctrl/Alt/Meta and lone modifier keys don't count (a shortcut
|
|
15
|
+
* or a screenshot isn't keyboard navigation), like the browsers'
|
|
16
|
+
* `:focus-visible` heuristic. A `preventDefault()`ed key still counts: an
|
|
17
|
+
* Escape that closes a modal and sends focus back is keyboard navigation,
|
|
18
|
+
* though Firefox then doesn't match `:focus-visible`.
|
|
19
|
+
*/
|
|
20
|
+
export function trackInputModality() {
|
|
21
|
+
if (state.listening || typeof document === 'undefined')
|
|
22
|
+
return;
|
|
23
|
+
state.listening = true;
|
|
24
|
+
doc.addEventListener('keydown', (e) => {
|
|
25
|
+
if (e.ctrlKey || e.altKey || e.metaKey || MODIFIER_KEYS.has(e.key))
|
|
26
|
+
return;
|
|
27
|
+
state.last = 'keyboard';
|
|
28
|
+
}, true);
|
|
29
|
+
doc.addEventListener('pointerdown', () => {
|
|
30
|
+
state.last = 'pointer';
|
|
31
|
+
}, true);
|
|
32
|
+
}
|
|
33
|
+
/** What the user last used, `null` before any input (or before `trackInputModality()`). */
|
|
34
|
+
export function lastInputModality() {
|
|
35
|
+
return state.last;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether focus on `el` came from the keyboard: from the last input when
|
|
39
|
+
* there was one, else (focus moved by script on load, `autofocus`) from the
|
|
40
|
+
* browser's `:focus-visible`, and `true` where that selector is unsupported.
|
|
41
|
+
*/
|
|
42
|
+
export function isKeyboardFocus(el) {
|
|
43
|
+
if (state.last)
|
|
44
|
+
return state.last === 'keyboard';
|
|
45
|
+
try {
|
|
46
|
+
return el.matches(':focus-visible');
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Forgets the last input. Tests only. */
|
|
53
|
+
export function resetInputModality() {
|
|
54
|
+
state.last = null;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=input-modality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-modality.js","sourceRoot":"","sources":["../../src/core/input-modality.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAUpC;;;;GAIG;AACH,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAC7D,MAAM,KAAK,GAAG,UAAkE,CAAC;AACjF,MAAM,KAAK,GAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAErF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,KAAK,CAAC,SAAS,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAC/D,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,GAAG,CAAC,gBAAgB,CAClB,SAAS,EACT,CAAC,CAAC,EAAE,EAAE;QACJ,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAAE,OAAO;QAC3E,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;IAC1B,CAAC,EACD,IAAI,CACL,CAAC;IACF,GAAG,CAAC,gBAAgB,CAClB,aAAa,EACb,GAAG,EAAE;QACH,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;IACzB,CAAC,EACD,IAAI,CACL,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,iBAAiB;IAC/B,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,EAAW;IACzC,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;IACjD,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,kBAAkB;IAChC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;AACpB,CAAC"}
|
package/dist/core/sanitize.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TrustedHTML } from './trusted-types.js';
|
|
1
2
|
export declare const nodeChildNodes: (node: unknown) => NodeListOf<ChildNode>;
|
|
2
3
|
/** Parses `source` as markup and returns it sanitized, as a string. Only for `String()` fallbacks: rendering inserts the nodes from `parseSanitized()` instead. */
|
|
3
4
|
export declare function sanitizeMarkup(source: string): string;
|
|
@@ -7,5 +8,9 @@ export declare function sanitizeMarkup(source: string): string;
|
|
|
7
8
|
* and returns the resulting nodes.
|
|
8
9
|
*/
|
|
9
10
|
export declare function parseSanitized(source: string, parent: Node | null): Node[];
|
|
10
|
-
/**
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Parses `source` as markup with an element like `parent` as context,
|
|
13
|
+
* unsanitized: the holder of the parsed nodes. `source` is written as given:
|
|
14
|
+
* under a Trusted Types CSP it must already be `TrustedHTML`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseInContext(source: string | TrustedHTML, parent: Node | null): ParentNode;
|
package/dist/core/sanitize.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { builtIn } from './builtin.js';
|
|
2
2
|
import { doc } from './safe-dom.js';
|
|
3
|
+
import { toTrustedHTML } from './trusted-types.js';
|
|
3
4
|
/**
|
|
4
5
|
* DOM-based sanitizer behind `raw()`: markup is parsed once in the inert
|
|
5
6
|
* document behind a `<template>` (nothing loads or runs there), cleaned as
|
|
@@ -68,7 +69,7 @@ const SCRIPT_OR_DATA_URL = /^(javascript|data):/i;
|
|
|
68
69
|
/** Parses `source` as markup and returns it sanitized, as a string. Only for `String()` fallbacks: rendering inserts the nodes from `parseSanitized()` instead. */
|
|
69
70
|
export function sanitizeMarkup(source) {
|
|
70
71
|
const holder = doc.createElement('template');
|
|
71
|
-
holder
|
|
72
|
+
setHTML(holder, toTrustedHTML(source));
|
|
72
73
|
sanitizeTemplate(holder);
|
|
73
74
|
return holder.innerHTML;
|
|
74
75
|
}
|
|
@@ -78,22 +79,30 @@ export function sanitizeMarkup(source) {
|
|
|
78
79
|
* and returns the resulting nodes.
|
|
79
80
|
*/
|
|
80
81
|
export function parseSanitized(source, parent) {
|
|
81
|
-
const root = parseInContext(source, parent);
|
|
82
|
+
const root = parseInContext(toTrustedHTML(source), parent);
|
|
82
83
|
sanitizeNode(root);
|
|
83
84
|
return Array.from(nodeChildNodes(root));
|
|
84
85
|
}
|
|
85
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Parses `source` as markup with an element like `parent` as context,
|
|
88
|
+
* unsanitized: the holder of the parsed nodes. `source` is written as given:
|
|
89
|
+
* under a Trusted Types CSP it must already be `TrustedHTML`.
|
|
90
|
+
*/
|
|
86
91
|
export function parseInContext(source, parent) {
|
|
87
92
|
const holder = doc.createElement('template');
|
|
88
93
|
const parentEl = parent && nodeType(parent) === ELEMENT_NODE ? parent : null;
|
|
89
94
|
if (parentEl && !templateContent(parentEl)) {
|
|
90
95
|
const context = holder.content.ownerDocument.createElementNS(elementNamespace(parentEl), elementLocalName(parentEl));
|
|
91
|
-
context
|
|
96
|
+
setHTML(context, source);
|
|
92
97
|
return context;
|
|
93
98
|
}
|
|
94
|
-
holder
|
|
99
|
+
setHTML(holder, source);
|
|
95
100
|
return holder.content;
|
|
96
101
|
}
|
|
102
|
+
/** `innerHTML` takes `TrustedHTML` as it does a string; TypeScript's DOM lib only knows the string. */
|
|
103
|
+
function setHTML(el, source) {
|
|
104
|
+
el.innerHTML = source;
|
|
105
|
+
}
|
|
97
106
|
function isAllowedAttribute(name, value) {
|
|
98
107
|
// srcdoc is parsed as a same-origin document: escaped markup in it is decoded and runs.
|
|
99
108
|
if (name.startsWith('on') || name === 'srcdoc')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../src/core/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../src/core/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,aAAa,EAAoB,MAAM,oBAAoB,CAAC;AAErE;;;;;;GAMG;AAEH,mLAAmL;AACnL,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3E,0EAA0E;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+
import { type TrustedHTML } from './trusted-types.js';
|
|
1
2
|
/**
|
|
2
3
|
* Markup to insert as HTML rather than as text: made by `raw()` (sanitized)
|
|
3
4
|
* or `trustedRaw()` (as is). Anywhere this library takes content — a `h()`
|
|
@@ -23,8 +24,16 @@ export interface Raw {
|
|
|
23
24
|
* (`name="createElement"`, `name="action"`, `id="body"`, …).
|
|
24
25
|
*/
|
|
25
26
|
export declare function raw(value: string): Raw;
|
|
26
|
-
/**
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Markup inserted exactly as given, unsanitized. Only for markup you wrote
|
|
29
|
+
* yourself — never for anything user input can reach.
|
|
30
|
+
*
|
|
31
|
+
* Under a Trusted Types CSP (`require-trusted-types-for 'script'`) pass a
|
|
32
|
+
* `TrustedHTML` made by your own policy: a plain string is rejected by the
|
|
33
|
+
* browser when it is inserted. The library's `a11y-elements` policy only
|
|
34
|
+
* covers `raw()`, which it sanitizes.
|
|
35
|
+
*/
|
|
36
|
+
export declare function trustedRaw(value: string | TrustedHTML): Raw;
|
|
28
37
|
export declare function isRaw(value: unknown): value is Raw;
|
|
29
38
|
/**
|
|
30
39
|
* Parses `value` with `parent` as context and returns its nodes, sanitized
|
package/dist/core/template.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { nodeChildNodes, parseInContext, parseSanitized, sanitizeMarkup } from './sanitize.js';
|
|
2
|
+
import { isTrustedHTML } from './trusted-types.js';
|
|
2
3
|
/**
|
|
3
|
-
* Brands, through `Symbol.for` rather than module-local symbols:
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Brands, through `Symbol.for` rather than module-local symbols: a page can
|
|
5
|
+
* hold more than one copy of this module, and markup made through one copy
|
|
6
|
+
* must stay recognized in another. The `dist/browser` entries share a single
|
|
7
|
+
* copy (code splitting puts it in one chunk), but `dist/core` loaded
|
|
8
|
+
* alongside `dist/browser`, or two versions of the package, are two.
|
|
6
9
|
*/
|
|
7
10
|
const RAW = Symbol.for('a11y-elements/raw');
|
|
8
|
-
/** The markup as given. */
|
|
11
|
+
/** The markup as given, always a string: copies of the library before 1.1 read it, and sanitize anything else. */
|
|
9
12
|
const SOURCE = Symbol.for('a11y-elements/raw-source');
|
|
13
|
+
/** Set by `trustedRaw()` when given a `TrustedHTML`: what is written to the sink. 1.1+ only. */
|
|
14
|
+
const TRUSTED_HTML = Symbol.for('a11y-elements/raw-trusted-html');
|
|
10
15
|
/** Set by `trustedRaw()`: insert unsanitized. */
|
|
11
16
|
const TRUSTED = Symbol.for('a11y-elements/raw-trusted');
|
|
12
17
|
class Markup {
|
|
13
18
|
[RAW] = true;
|
|
14
19
|
[SOURCE];
|
|
15
20
|
[TRUSTED];
|
|
16
|
-
|
|
21
|
+
[TRUSTED_HTML];
|
|
22
|
+
constructor(source, trusted, trustedHtml) {
|
|
17
23
|
this[SOURCE] = source;
|
|
18
24
|
this[TRUSTED] = trusted;
|
|
25
|
+
if (trustedHtml)
|
|
26
|
+
this[TRUSTED_HTML] = trustedHtml;
|
|
19
27
|
}
|
|
20
28
|
get __html() {
|
|
21
29
|
return this.toString();
|
|
@@ -34,8 +42,18 @@ class Markup {
|
|
|
34
42
|
export function raw(value) {
|
|
35
43
|
return new Markup(value == null ? '' : String(value), false);
|
|
36
44
|
}
|
|
37
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Markup inserted exactly as given, unsanitized. Only for markup you wrote
|
|
47
|
+
* yourself — never for anything user input can reach.
|
|
48
|
+
*
|
|
49
|
+
* Under a Trusted Types CSP (`require-trusted-types-for 'script'`) pass a
|
|
50
|
+
* `TrustedHTML` made by your own policy: a plain string is rejected by the
|
|
51
|
+
* browser when it is inserted. The library's `a11y-elements` policy only
|
|
52
|
+
* covers `raw()`, which it sanitizes.
|
|
53
|
+
*/
|
|
38
54
|
export function trustedRaw(value) {
|
|
55
|
+
if (isTrustedHTML(value))
|
|
56
|
+
return new Markup(String(value), true, value);
|
|
39
57
|
return new Markup(value == null ? '' : String(value), true);
|
|
40
58
|
}
|
|
41
59
|
export function isRaw(value) {
|
|
@@ -51,8 +69,10 @@ export function rawNodes(value, parent) {
|
|
|
51
69
|
const source = brand[SOURCE];
|
|
52
70
|
if (typeof source !== 'string')
|
|
53
71
|
return parseSanitized(value.__html, parent);
|
|
54
|
-
if (brand[TRUSTED] === true)
|
|
55
|
-
|
|
72
|
+
if (brand[TRUSTED] === true) {
|
|
73
|
+
const trustedHtml = brand[TRUSTED_HTML];
|
|
74
|
+
return Array.from(nodeChildNodes(parseInContext(isTrustedHTML(trustedHtml) ? trustedHtml : source, parent)));
|
|
75
|
+
}
|
|
56
76
|
return parseSanitized(source, parent);
|
|
57
77
|
}
|
|
58
78
|
//# sourceMappingURL=template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAoB,MAAM,oBAAoB,CAAC;AAoBrE;;;;;;GAMG;AACH,MAAM,GAAG,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC3D,kHAAkH;AAClH,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AACrE,gGAAgG;AAChG,MAAM,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AACjF,iDAAiD;AACjD,MAAM,OAAO,GAAkB,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAEvE,MAAM,MAAM;IACD,CAAC,GAAG,CAAC,GAAG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AAK,IAAI,CAAC;AACzG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAU,EAAE,MAAmB;IACtD,MAAM,KAAK,GAAG,KAA2C,CAAC;IAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/G,CAAC;IACD,OAAO,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trusted Types, opt-in: used only where `trustedTypes` exists, so pages
|
|
3
|
+
* without a Trusted Types CSP see no change.
|
|
4
|
+
*
|
|
5
|
+
* The `a11y-elements` policy passes markup through as it is. That's safe
|
|
6
|
+
* only because of where it is used: `raw()` markup is parsed into the inert
|
|
7
|
+
* document behind a `<template>` (nothing loads or runs there) and sanitized
|
|
8
|
+
* as nodes before anything is attached to the page. It is never used for
|
|
9
|
+
* `trustedRaw()`, whose markup is inserted unsanitized: under a Trusted Types
|
|
10
|
+
* CSP that needs a `TrustedHTML` made by the host's own policy.
|
|
11
|
+
*
|
|
12
|
+
* - Never a `default` policy, which would pass every sink on the page.
|
|
13
|
+
* - Created on first use, so a copy of the library that never renders never
|
|
14
|
+
* asks for the name.
|
|
15
|
+
* - Module-private: no way to reach it from outside, so listing
|
|
16
|
+
* `a11y-elements` in `trusted-types` allows only this parse step. A second
|
|
17
|
+
* copy that renders on the same page gets a duplicate-name error unless the
|
|
18
|
+
* CSP has `'allow-duplicates'`: it warns once and writes plain strings,
|
|
19
|
+
* which the browser then rejects.
|
|
20
|
+
*/
|
|
21
|
+
export declare const POLICY_NAME = "a11y-elements";
|
|
22
|
+
/**
|
|
23
|
+
* A `TrustedHTML` value (TypeScript's DOM lib doesn't declare the type yet).
|
|
24
|
+
* `@types/trusted-types` brands its own with a private member, so its public
|
|
25
|
+
* shape is empty and no brand here could match it. Instead this rules out
|
|
26
|
+
* the likely mistakes: primitives (`object`) and DOM nodes (`nodeType`).
|
|
27
|
+
*/
|
|
28
|
+
export type TrustedHTML = object & {
|
|
29
|
+
readonly nodeType?: never;
|
|
30
|
+
};
|
|
31
|
+
/** Whether `value` is a real `TrustedHTML`; always false where Trusted Types don't exist. */
|
|
32
|
+
export declare function isTrustedHTML(value: unknown): value is TrustedHTML;
|
|
33
|
+
/** `markup` as `TrustedHTML` where Trusted Types exist, else as is. Only for markup parsed into an inert template and sanitized before use. */
|
|
34
|
+
export declare function toTrustedHTML(markup: string): string | TrustedHTML;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trusted Types, opt-in: used only where `trustedTypes` exists, so pages
|
|
3
|
+
* without a Trusted Types CSP see no change.
|
|
4
|
+
*
|
|
5
|
+
* The `a11y-elements` policy passes markup through as it is. That's safe
|
|
6
|
+
* only because of where it is used: `raw()` markup is parsed into the inert
|
|
7
|
+
* document behind a `<template>` (nothing loads or runs there) and sanitized
|
|
8
|
+
* as nodes before anything is attached to the page. It is never used for
|
|
9
|
+
* `trustedRaw()`, whose markup is inserted unsanitized: under a Trusted Types
|
|
10
|
+
* CSP that needs a `TrustedHTML` made by the host's own policy.
|
|
11
|
+
*
|
|
12
|
+
* - Never a `default` policy, which would pass every sink on the page.
|
|
13
|
+
* - Created on first use, so a copy of the library that never renders never
|
|
14
|
+
* asks for the name.
|
|
15
|
+
* - Module-private: no way to reach it from outside, so listing
|
|
16
|
+
* `a11y-elements` in `trusted-types` allows only this parse step. A second
|
|
17
|
+
* copy that renders on the same page gets a duplicate-name error unless the
|
|
18
|
+
* CSP has `'allow-duplicates'`: it warns once and writes plain strings,
|
|
19
|
+
* which the browser then rejects.
|
|
20
|
+
*/
|
|
21
|
+
import { doc } from './safe-dom.js';
|
|
22
|
+
export const POLICY_NAME = 'a11y-elements';
|
|
23
|
+
/**
|
|
24
|
+
* The page's `trustedTypes`, if it is the real one. Where the browser has
|
|
25
|
+
* none, an element with `id="trustedTypes"` (which `raw()` content can carry)
|
|
26
|
+
* is what `window.trustedTypes` returns: check for its methods.
|
|
27
|
+
*/
|
|
28
|
+
function factory() {
|
|
29
|
+
const tt = globalThis.trustedTypes;
|
|
30
|
+
return tt && typeof tt.createPolicy === 'function' && typeof tt.isHTML === 'function' ? tt : undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Whether a plain string written to an HTML sink is rejected, i.e. the CSP
|
|
34
|
+
* has `require-trusted-types-for 'script'`. Probed only once a policy
|
|
35
|
+
* couldn't be created; under enforcement the probe itself adds one
|
|
36
|
+
* violation report.
|
|
37
|
+
*/
|
|
38
|
+
function enforced() {
|
|
39
|
+
try {
|
|
40
|
+
doc.createElement('template').innerHTML = '';
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Whether `value` is a real `TrustedHTML`; always false where Trusted Types don't exist. */
|
|
48
|
+
export function isTrustedHTML(value) {
|
|
49
|
+
return typeof value === 'object' && value !== null && factory()?.isHTML(value) === true;
|
|
50
|
+
}
|
|
51
|
+
let policy;
|
|
52
|
+
let failed = false;
|
|
53
|
+
function getPolicy() {
|
|
54
|
+
if (policy || failed)
|
|
55
|
+
return policy;
|
|
56
|
+
const tt = factory();
|
|
57
|
+
if (!tt)
|
|
58
|
+
return undefined;
|
|
59
|
+
try {
|
|
60
|
+
policy = tt.createPolicy(POLICY_NAME, { createHTML: (markup) => markup });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// Not listed in the CSP's `trusted-types`, or a second copy without 'allow-duplicates'.
|
|
64
|
+
// Without enforcement plain strings still work: a `trusted-types` list alone isn't worth a warning.
|
|
65
|
+
failed = true;
|
|
66
|
+
if (!enforced())
|
|
67
|
+
return undefined;
|
|
68
|
+
console.warn(`a11y-elements: could not create the "${POLICY_NAME}" Trusted Types policy. ` +
|
|
69
|
+
`List ${POLICY_NAME} in the CSP's trusted-types, and add 'allow-duplicates' if more than one copy of a11y-elements is loaded.`, error);
|
|
70
|
+
}
|
|
71
|
+
return policy;
|
|
72
|
+
}
|
|
73
|
+
/** `markup` as `TrustedHTML` where Trusted Types exist, else as is. Only for markup parsed into an inert template and sanitized before use. */
|
|
74
|
+
export function toTrustedHTML(markup) {
|
|
75
|
+
const p = getPolicy();
|
|
76
|
+
return p ? p.createHTML(markup) : markup;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=trusted-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trusted-types.js","sourceRoot":"","sources":["../../src/core/trusted-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAmB3C;;;;GAIG;AACH,SAAS,OAAO;IACd,MAAM,EAAE,GAAI,UAA8D,CAAC,YAAY,CAAC;IACxF,OAAO,EAAE,IAAI,OAAO,EAAE,CAAC,YAAY,KAAK,UAAU,IAAI,OAAO,EAAE,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAE,EAA0B,CAAC,CAAC,CAAC,SAAS,CAAC;AAClI,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ;IACf,IAAI,CAAC;QACH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3C,CAAC"}
|
|
@@ -25,6 +25,10 @@ export declare abstract class A11yAnchoredOverlayElement extends A11yOverlayElem
|
|
|
25
25
|
private _focusTrap;
|
|
26
26
|
private _boundOutsideClick;
|
|
27
27
|
private _outsideClickTimer;
|
|
28
|
+
/** The `<html>` given the no-op click listener, kept to remove it from the same element. */
|
|
29
|
+
private _tapTargetRoot;
|
|
30
|
+
/** Per instance: a shared function would be added once, and the first overlay to close would remove it for all. */
|
|
31
|
+
private _noopClick;
|
|
28
32
|
private _boundKeyDown;
|
|
29
33
|
private _boundReposition;
|
|
30
34
|
private _resizeObserver;
|