a11y-elements 1.0.3 → 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.
Files changed (39) hide show
  1. package/README.md +16 -0
  2. package/dist/browser/all.js +9 -9
  3. package/dist/browser/{chunk-OB2NQV77.js → chunk-3QCORK3F.js} +2 -2
  4. package/dist/browser/{chunk-7CL7TH7I.js → chunk-4ER4RFUO.js} +2 -2
  5. package/dist/browser/{chunk-MIBUA46B.js → chunk-6HI2FNGK.js} +2 -2
  6. package/dist/browser/{chunk-KVUJT6BC.js → chunk-7FIT24VV.js} +56 -7
  7. package/dist/browser/chunk-7FIT24VV.js.map +1 -0
  8. package/dist/browser/{chunk-NT7DOWM7.js → chunk-CDDBLEN6.js} +2 -2
  9. package/dist/browser/{chunk-GA3VPLST.js → chunk-GNAF4MSU.js} +2 -2
  10. package/dist/browser/{chunk-2HQKZFJV.js → chunk-ONS5T35N.js} +2 -2
  11. package/dist/browser/{chunk-GYM3EIL3.js → chunk-RKZNZKLG.js} +2 -2
  12. package/dist/browser/{chunk-HJUKOWFZ.js → chunk-TU4BZYED.js} +2 -2
  13. package/dist/browser/components/avatar/define.js +2 -2
  14. package/dist/browser/components/progress/define.js +2 -2
  15. package/dist/browser/components/skeleton/define.js +2 -2
  16. package/dist/browser/components/spinner/define.js +2 -2
  17. package/dist/browser/overlays/blocking-loader/define.js +3 -3
  18. package/dist/browser/overlays/modal/define.js +2 -2
  19. package/dist/browser/overlays/notification-banner/define.js +2 -2
  20. package/dist/browser/overlays/snackbar/define.js +2 -2
  21. package/dist/core/sanitize.d.ts +7 -2
  22. package/dist/core/sanitize.js +14 -5
  23. package/dist/core/sanitize.js.map +1 -1
  24. package/dist/core/template.d.ts +11 -2
  25. package/dist/core/template.js +28 -8
  26. package/dist/core/template.js.map +1 -1
  27. package/dist/core/trusted-types.d.ts +34 -0
  28. package/dist/core/trusted-types.js +78 -0
  29. package/dist/core/trusted-types.js.map +1 -0
  30. package/package.json +1 -1
  31. package/dist/browser/chunk-KVUJT6BC.js.map +0 -1
  32. /package/dist/browser/{chunk-OB2NQV77.js.map → chunk-3QCORK3F.js.map} +0 -0
  33. /package/dist/browser/{chunk-7CL7TH7I.js.map → chunk-4ER4RFUO.js.map} +0 -0
  34. /package/dist/browser/{chunk-MIBUA46B.js.map → chunk-6HI2FNGK.js.map} +0 -0
  35. /package/dist/browser/{chunk-NT7DOWM7.js.map → chunk-CDDBLEN6.js.map} +0 -0
  36. /package/dist/browser/{chunk-GA3VPLST.js.map → chunk-GNAF4MSU.js.map} +0 -0
  37. /package/dist/browser/{chunk-2HQKZFJV.js.map → chunk-ONS5T35N.js.map} +0 -0
  38. /package/dist/browser/{chunk-GYM3EIL3.js.map → chunk-RKZNZKLG.js.map} +0 -0
  39. /package/dist/browser/{chunk-HJUKOWFZ.js.map → chunk-TU4BZYED.js.map} +0 -0
package/README.md CHANGED
@@ -101,6 +101,22 @@ import { A11yElement } from 'a11y-elements/core';
101
101
 
102
102
  Importing a component's subpath also adds its tag to TypeScript's `HTMLElementTagNameMap`, so exact-tag lookups such as `document.createElement('a11y-checkbox')` or `document.querySelector('a11y-checkbox')` come back typed as `CheckboxElement` without a cast.
103
103
 
104
+ ### Trusted Types (CSP)
105
+
106
+ On a page whose Content Security Policy has `require-trusted-types-for 'script'`, list `a11y-elements` in `trusted-types`:
107
+
108
+ ```
109
+ Content-Security-Policy: require-trusted-types-for 'script'; trusted-types a11y-elements <your own policies>
110
+ ```
111
+
112
+ Without Trusted Types nothing changes. With them:
113
+
114
+ * **The `a11y-elements` policy only covers `raw()`.** It is created the first time `raw()` markup is parsed. It passes that markup through unchanged: the markup is parsed into the inert document behind a `<template>` (nothing loads or runs there), then sanitized as nodes before anything reaches the page. The policy is private to the library, so no other script can use it. The library never creates a `default` policy.
115
+ * **`trustedRaw()` needs a `TrustedHTML`.** Its markup is inserted unsanitized, so it doesn't go through the library's policy: pass it a value made by your own policy, e.g. `trustedRaw(myPolicy.createHTML(markup))`. A plain string is rejected by the browser when the content is inserted.
116
+ * **`String(raw(…))` and `.__html` are strings.** If you assign them to `innerHTML` yourself, that's your own sink, and it needs your own policy.
117
+ * **Loading two copies of the library** (two versions, or `dist/core` alongside `dist/browser`) makes two policies with the same name. The second copy to render logs a warning and its content is rejected, unless the CSP allows duplicates: `trusted-types a11y-elements 'allow-duplicates'`. One `dist/browser` load is a single copy: its elements share one chunk.
118
+ * `h()` sets attributes with `setAttribute()`, so `h('script', { src })` is a Trusted Types sink of yours, and the browser rejects it without a `TrustedScriptURL`.
119
+
104
120
  ### Translating built-in strings
105
121
 
106
122
  A few English strings end up in accessible names and announcements. Replace them page-wide with `setStrings()`, exported from `a11y-elements/core` and from every zero-build `define.js`:
@@ -4,18 +4,18 @@ import {
4
4
  import {
5
5
  ModalElement,
6
6
  confirmDialog
7
- } from "./chunk-2HQKZFJV.js";
7
+ } from "./chunk-ONS5T35N.js";
8
8
  import {
9
9
  NotificationBannerElement,
10
10
  showNotificationBanner
11
- } from "./chunk-HJUKOWFZ.js";
11
+ } from "./chunk-TU4BZYED.js";
12
12
  import {
13
13
  PopoverElement
14
14
  } from "./chunk-3AHPI6C5.js";
15
15
  import {
16
16
  SnackbarElement,
17
17
  notify
18
- } from "./chunk-GYM3EIL3.js";
18
+ } from "./chunk-RKZNZKLG.js";
19
19
  import "./chunk-YYYJ6D77.js";
20
20
  import {
21
21
  TooltipElement
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-SRWD5UK6.js";
32
32
  import {
33
33
  BlockingLoaderElement
34
- } from "./chunk-OB2NQV77.js";
34
+ } from "./chunk-3QCORK3F.js";
35
35
  import {
36
36
  ContextMenuElement
37
37
  } from "./chunk-B6V4HID2.js";
@@ -62,7 +62,7 @@ import {
62
62
  } from "./chunk-F5VLI6QP.js";
63
63
  import {
64
64
  ProgressElement
65
- } from "./chunk-MIBUA46B.js";
65
+ } from "./chunk-6HI2FNGK.js";
66
66
  import {
67
67
  RadioGroupElement
68
68
  } from "./chunk-P42G35OU.js";
@@ -71,10 +71,10 @@ import {
71
71
  } from "./chunk-NJSZSBR5.js";
72
72
  import {
73
73
  SkeletonElement
74
- } from "./chunk-GA3VPLST.js";
74
+ } from "./chunk-GNAF4MSU.js";
75
75
  import {
76
76
  SpinnerElement
77
- } from "./chunk-NT7DOWM7.js";
77
+ } from "./chunk-CDDBLEN6.js";
78
78
  import {
79
79
  SwitchElement
80
80
  } from "./chunk-UFLTXMN2.js";
@@ -83,8 +83,8 @@ import {
83
83
  } from "./chunk-HG7FJAXE.js";
84
84
  import {
85
85
  AvatarElement
86
- } from "./chunk-7CL7TH7I.js";
87
- import "./chunk-KVUJT6BC.js";
86
+ } from "./chunk-4ER4RFUO.js";
87
+ import "./chunk-7FIT24VV.js";
88
88
  import {
89
89
  CardLinkElement
90
90
  } from "./chunk-6AJBXOCZ.js";
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-H25W66MH.js";
12
12
  import {
13
13
  h
14
- } from "./chunk-KVUJT6BC.js";
14
+ } from "./chunk-7FIT24VV.js";
15
15
  import {
16
16
  defineElement,
17
17
  getString
@@ -74,4 +74,4 @@ defineElement("a11y-blocking-loader", BlockingLoaderElement);
74
74
  export {
75
75
  BlockingLoaderElement
76
76
  };
77
- //# sourceMappingURL=chunk-OB2NQV77.js.map
77
+ //# sourceMappingURL=chunk-3QCORK3F.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  h,
3
3
  setAttrs
4
- } from "./chunk-KVUJT6BC.js";
4
+ } from "./chunk-7FIT24VV.js";
5
5
  import {
6
6
  A11yElement,
7
7
  defineElement,
@@ -79,4 +79,4 @@ defineElement("a11y-avatar", AvatarElement);
79
79
  export {
80
80
  AvatarElement
81
81
  };
82
- //# sourceMappingURL=chunk-7CL7TH7I.js.map
82
+ //# sourceMappingURL=chunk-4ER4RFUO.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  h,
3
3
  setAttrs
4
- } from "./chunk-KVUJT6BC.js";
4
+ } from "./chunk-7FIT24VV.js";
5
5
  import {
6
6
  nextId
7
7
  } from "./chunk-Q4TMA3P7.js";
@@ -66,4 +66,4 @@ defineElement("a11y-progress", ProgressElement);
66
66
  export {
67
67
  ProgressElement
68
68
  };
69
- //# sourceMappingURL=chunk-MIBUA46B.js.map
69
+ //# sourceMappingURL=chunk-6HI2FNGK.js.map
@@ -4,6 +4,46 @@ import {
4
4
  doc
5
5
  } from "./chunk-ED3UMYMY.js";
6
6
 
7
+ // src/core/trusted-types.ts
8
+ var POLICY_NAME = "a11y-elements";
9
+ function factory() {
10
+ const tt = globalThis.trustedTypes;
11
+ return tt && typeof tt.createPolicy === "function" && typeof tt.isHTML === "function" ? tt : void 0;
12
+ }
13
+ function enforced() {
14
+ try {
15
+ doc.createElement("template").innerHTML = "";
16
+ return false;
17
+ } catch {
18
+ return true;
19
+ }
20
+ }
21
+ function isTrustedHTML(value) {
22
+ return typeof value === "object" && value !== null && factory()?.isHTML(value) === true;
23
+ }
24
+ var policy;
25
+ var failed = false;
26
+ function getPolicy() {
27
+ if (policy || failed) return policy;
28
+ const tt = factory();
29
+ if (!tt) return void 0;
30
+ try {
31
+ policy = tt.createPolicy(POLICY_NAME, { createHTML: (markup) => markup });
32
+ } catch (error) {
33
+ failed = true;
34
+ if (!enforced()) return void 0;
35
+ console.warn(
36
+ `a11y-elements: could not create the "${POLICY_NAME}" Trusted Types policy. List ${POLICY_NAME} in the CSP's trusted-types, and add 'allow-duplicates' if more than one copy of a11y-elements is loaded.`,
37
+ error
38
+ );
39
+ }
40
+ return policy;
41
+ }
42
+ function toTrustedHTML(markup) {
43
+ const p = getPolicy();
44
+ return p ? p.createHTML(markup) : markup;
45
+ }
46
+
7
47
  // src/core/sanitize.ts
8
48
  var STRIPPED_TAGS = /* @__PURE__ */ new Set(["script", "style", "link", "base", "meta"]);
9
49
  var FRAME_TAGS = /* @__PURE__ */ new Set(["iframe", "object", "embed", "frame"]);
@@ -39,12 +79,12 @@ function childrenOf(root) {
39
79
  var SCRIPT_OR_DATA_URL = /^(javascript|data):/i;
40
80
  function sanitizeMarkup(source) {
41
81
  const holder = doc.createElement("template");
42
- holder.innerHTML = source;
82
+ setHTML(holder, toTrustedHTML(source));
43
83
  sanitizeTemplate(holder);
44
84
  return holder.innerHTML;
45
85
  }
46
86
  function parseSanitized(source, parent) {
47
- const root = parseInContext(source, parent);
87
+ const root = parseInContext(toTrustedHTML(source), parent);
48
88
  sanitizeNode(root);
49
89
  return Array.from(nodeChildNodes(root));
50
90
  }
@@ -53,12 +93,15 @@ function parseInContext(source, parent) {
53
93
  const parentEl = parent && nodeType(parent) === ELEMENT_NODE ? parent : null;
54
94
  if (parentEl && !templateContent(parentEl)) {
55
95
  const context = holder.content.ownerDocument.createElementNS(elementNamespace(parentEl), elementLocalName(parentEl));
56
- context.innerHTML = source;
96
+ setHTML(context, source);
57
97
  return context;
58
98
  }
59
- holder.innerHTML = source;
99
+ setHTML(holder, source);
60
100
  return holder.content;
61
101
  }
102
+ function setHTML(el, source) {
103
+ el.innerHTML = source;
104
+ }
62
105
  function isAllowedAttribute(name, value) {
63
106
  if (name.startsWith("on") || name === "srcdoc") return false;
64
107
  return !(URL_ATTRS.has(name) && isDangerousUrl(value, SCRIPT_URL));
@@ -101,14 +144,17 @@ function isDangerousUrl(value, schemes) {
101
144
  // src/core/template.ts
102
145
  var RAW = /* @__PURE__ */ Symbol.for("a11y-elements/raw");
103
146
  var SOURCE = /* @__PURE__ */ Symbol.for("a11y-elements/raw-source");
147
+ var TRUSTED_HTML = /* @__PURE__ */ Symbol.for("a11y-elements/raw-trusted-html");
104
148
  var TRUSTED = /* @__PURE__ */ Symbol.for("a11y-elements/raw-trusted");
105
149
  var Markup = class {
106
150
  [RAW] = true;
107
151
  [SOURCE];
108
152
  [TRUSTED];
109
- constructor(source, trusted) {
153
+ [TRUSTED_HTML];
154
+ constructor(source, trusted, trustedHtml) {
110
155
  this[SOURCE] = source;
111
156
  this[TRUSTED] = trusted;
157
+ if (trustedHtml) this[TRUSTED_HTML] = trustedHtml;
112
158
  }
113
159
  get __html() {
114
160
  return this.toString();
@@ -124,7 +170,10 @@ function rawNodes(value, parent) {
124
170
  const brand = value;
125
171
  const source = brand[SOURCE];
126
172
  if (typeof source !== "string") return parseSanitized(value.__html, parent);
127
- if (brand[TRUSTED] === true) return Array.from(nodeChildNodes(parseInContext(source, parent)));
173
+ if (brand[TRUSTED] === true) {
174
+ const trustedHtml = brand[TRUSTED_HTML];
175
+ return Array.from(nodeChildNodes(parseInContext(isTrustedHTML(trustedHtml) ? trustedHtml : source, parent)));
176
+ }
128
177
  return parseSanitized(source, parent);
129
178
  }
130
179
 
@@ -156,4 +205,4 @@ export {
156
205
  h,
157
206
  setAttrs
158
207
  };
159
- //# sourceMappingURL=chunk-KVUJT6BC.js.map
208
+ //# sourceMappingURL=chunk-7FIT24VV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/trusted-types.ts","../../src/core/sanitize.ts","../../src/core/template.ts","../../src/core/dom.ts"],"sourcesContent":["/**\n * Trusted Types, opt-in: used only where `trustedTypes` exists, so pages\n * without a Trusted Types CSP see no change.\n *\n * The `a11y-elements` policy passes markup through as it is. That's safe\n * only because of where it is used: `raw()` markup is parsed into the inert\n * document behind a `<template>` (nothing loads or runs there) and sanitized\n * as nodes before anything is attached to the page. It is never used for\n * `trustedRaw()`, whose markup is inserted unsanitized: under a Trusted Types\n * CSP that needs a `TrustedHTML` made by the host's own policy.\n *\n * - Never a `default` policy, which would pass every sink on the page.\n * - Created on first use, so a copy of the library that never renders never\n * asks for the name.\n * - Module-private: no way to reach it from outside, so listing\n * `a11y-elements` in `trusted-types` allows only this parse step. A second\n * copy that renders on the same page gets a duplicate-name error unless the\n * CSP has `'allow-duplicates'`: it warns once and writes plain strings,\n * which the browser then rejects.\n */\n\nimport { doc } from './safe-dom.js';\n\nexport const POLICY_NAME = 'a11y-elements';\n\n/**\n * A `TrustedHTML` value (TypeScript's DOM lib doesn't declare the type yet).\n * `@types/trusted-types` brands its own with a private member, so its public\n * shape is empty and no brand here could match it. Instead this rules out\n * the likely mistakes: primitives (`object`) and DOM nodes (`nodeType`).\n */\nexport type TrustedHTML = object & { readonly nodeType?: never };\n\ninterface HtmlPolicy {\n createHTML(markup: string): TrustedHTML;\n}\n\ninterface TrustedTypesFactory {\n createPolicy(name: string, rules: { createHTML(markup: string): string }): HtmlPolicy;\n isHTML(value: unknown): boolean;\n}\n\n/**\n * The page's `trustedTypes`, if it is the real one. Where the browser has\n * none, an element with `id=\"trustedTypes\"` (which `raw()` content can carry)\n * is what `window.trustedTypes` returns: check for its methods.\n */\nfunction factory(): TrustedTypesFactory | undefined {\n const tt = (globalThis as { trustedTypes?: Partial<TrustedTypesFactory> }).trustedTypes;\n return tt && typeof tt.createPolicy === 'function' && typeof tt.isHTML === 'function' ? (tt as TrustedTypesFactory) : undefined;\n}\n\n/**\n * Whether a plain string written to an HTML sink is rejected, i.e. the CSP\n * has `require-trusted-types-for 'script'`. Probed only once a policy\n * couldn't be created; under enforcement the probe itself adds one\n * violation report.\n */\nfunction enforced(): boolean {\n try {\n doc.createElement('template').innerHTML = '';\n return false;\n } catch {\n return true;\n }\n}\n\n/** Whether `value` is a real `TrustedHTML`; always false where Trusted Types don't exist. */\nexport function isTrustedHTML(value: unknown): value is TrustedHTML {\n return typeof value === 'object' && value !== null && factory()?.isHTML(value) === true;\n}\n\nlet policy: HtmlPolicy | undefined;\nlet failed = false;\n\nfunction getPolicy(): HtmlPolicy | undefined {\n if (policy || failed) return policy;\n const tt = factory();\n if (!tt) return undefined;\n try {\n policy = tt.createPolicy(POLICY_NAME, { createHTML: (markup) => markup });\n } catch (error) {\n // Not listed in the CSP's `trusted-types`, or a second copy without 'allow-duplicates'.\n // Without enforcement plain strings still work: a `trusted-types` list alone isn't worth a warning.\n failed = true;\n if (!enforced()) return undefined;\n console.warn(\n `a11y-elements: could not create the \"${POLICY_NAME}\" Trusted Types policy. ` +\n `List ${POLICY_NAME} in the CSP's trusted-types, and add 'allow-duplicates' if more than one copy of a11y-elements is loaded.`,\n error,\n );\n }\n return policy;\n}\n\n/** `markup` as `TrustedHTML` where Trusted Types exist, else as is. Only for markup parsed into an inert template and sanitized before use. */\nexport function toTrustedHTML(markup: string): string | TrustedHTML {\n const p = getPolicy();\n return p ? p.createHTML(markup) : markup;\n}\n","import { builtIn } from './builtin.js';\nimport { doc } from './safe-dom.js';\nimport { toTrustedHTML, type TrustedHTML } from './trusted-types.js';\n\n/**\n * DOM-based sanitizer behind `raw()`: markup is parsed once in the inert\n * document behind a `<template>` (nothing loads or runs there), cleaned as\n * nodes, and those nodes are what gets inserted — never re-serialized and\n * parsed again, which is where mutation XSS turns inert text back into\n * elements.\n */\n\n/** Compared against `localName`, so SVG/MathML elements of the same name are caught too. style/link restyle the page, base moves every relative URL, meta can refresh/navigate. */\nconst STRIPPED_TAGS = new Set(['script', 'style', 'link', 'base', 'meta']);\n\n/** A `data:` document in a frame runs its own scripts (opaque origin). */\nconst FRAME_TAGS = new Set(['iframe', 'object', 'embed', 'frame']);\nconst FRAME_URL_ATTRS = new Set(['src', 'data']);\nconst URL_ATTRS = new Set(['href', 'src', 'action', 'formaction', 'poster', 'background', 'xlink:href']);\n\n/** SVG `<animate>`/`<set>` can rewrite an attribute after sanitization: those targeting a URL attribute are dropped. */\nconst ATTR_ANIMATION_TAGS = new Set(['animate', 'set']);\n\nconst SCRIPT_URL = /^javascript:/i;\n\n/**\n * `document` and `<form>` are `[LegacyOverrideBuiltIns]` too: once inserted,\n * `<img name=\"createElement\">` makes `document.createElement` that image, and\n * `<input name=\"action\">` shadows its form's `action`. An `id`/`name` whose\n * value names a property of either (or of a named element already on the\n * page) is dropped — DOMPurify's `SANITIZE_DOM`. Markup you write yourself,\n * or pass to `trustedRaw()`, keeps its names.\n */\nconst CLOBBERING_ATTRS = new Set(['id', 'name']);\nlet probeForm: HTMLFormElement | undefined;\n\nfunction clobbers(value: string): boolean {\n probeForm ??= doc.createElement('form');\n return value in document || value in probeForm;\n}\n\n/*\n * Clobbering-proof DOM access. A `<form>` is `[LegacyOverrideBuiltIns]`: a\n * descendant named `children`, `attributes`, `localName`, `remove`, … shadows\n * that property on the form itself, so reading `form.children` straight off\n * the element can return an attacker's `<img>` and make the walk skip it.\n * Every read below goes through the node's prototype chain instead (named\n * properties are own properties of the instance, never on a prototype).\n *\n * Resolved on each call, never captured at load: importing this module needs\n * no DOM, and non-spec DOMs used for SSR work too — linkedom puts `children`\n * on a mixin, has a stub `childNodes` on `Node.prototype` that subclasses\n * override, and sets `nodeType`/`localName` as data on each node.\n */\nfunction read<T>(node: unknown, name: string): T {\n const desc = builtIn(node as object, name);\n if (desc) return (desc.get ? desc.get.call(node) : desc.value) as T;\n // No prototype has it (per-node data, as in linkedom). Never an own getter.\n return Object.getOwnPropertyDescriptor(node as object, name)?.value as T;\n}\n\nfunction invoke<T>(node: unknown, name: string, ...args: unknown[]): T {\n return (builtIn(node as object, name)!.value as (...a: unknown[]) => T).apply(node, args);\n}\n\nexport const nodeChildNodes = (node: unknown): NodeListOf<ChildNode> => read(node, 'childNodes');\nconst nodeType = (node: unknown): number => read(node, 'nodeType');\nconst elementChildren = (node: unknown): HTMLCollection => read(node, 'children');\nconst elementAttributes = (el: Element): NamedNodeMap => read(el, 'attributes');\nconst elementLocalName = (el: Element): string => read(el, 'localName');\nconst elementNamespace = (el: Element): string | null => read(el, 'namespaceURI');\nconst templateContentOf = (el: Element): DocumentFragment => read(el, 'content');\n\nconst ELEMENT_NODE = 1;\n\nfunction childrenOf(root: ParentNode): Element[] {\n return Array.from(elementChildren(root));\n}\nconst SCRIPT_OR_DATA_URL = /^(javascript|data):/i;\n\n/** Parses `source` as markup and returns it sanitized, as a string. Only for `String()` fallbacks: rendering inserts the nodes from `parseSanitized()` instead. */\nexport function sanitizeMarkup(source: string): string {\n const holder = doc.createElement('template');\n setHTML(holder, toTrustedHTML(source));\n sanitizeTemplate(holder);\n return holder.innerHTML;\n}\n\n/**\n * Parses `source` with an element like `parent` as context (so `<tr>`, SVG\n * or MathML content parses as it will once inserted under it), sanitizes it,\n * and returns the resulting nodes.\n */\nexport function parseSanitized(source: string, parent: Node | null): Node[] {\n const root = parseInContext(toTrustedHTML(source), parent);\n sanitizeNode(root);\n return Array.from(nodeChildNodes(root));\n}\n\n/**\n * Parses `source` as markup with an element like `parent` as context,\n * unsanitized: the holder of the parsed nodes. `source` is written as given:\n * under a Trusted Types CSP it must already be `TrustedHTML`.\n */\nexport function parseInContext(source: string | TrustedHTML, parent: Node | null): ParentNode {\n const holder = doc.createElement('template');\n const parentEl = parent && nodeType(parent) === ELEMENT_NODE ? (parent as Element) : null;\n if (parentEl && !templateContent(parentEl)) {\n const context = holder.content.ownerDocument.createElementNS(elementNamespace(parentEl), elementLocalName(parentEl));\n setHTML(context, source);\n return context;\n }\n setHTML(holder, source);\n return holder.content;\n}\n\n/** `innerHTML` takes `TrustedHTML` as it does a string; TypeScript's DOM lib only knows the string. */\nfunction setHTML(el: Element, source: string | TrustedHTML): void {\n el.innerHTML = source as string;\n}\n\nfunction isAllowedAttribute(name: string, value: string): boolean {\n // srcdoc is parsed as a same-origin document: escaped markup in it is decoded and runs.\n if (name.startsWith('on') || name === 'srcdoc') return false;\n return !(URL_ATTRS.has(name) && isDangerousUrl(value, SCRIPT_URL));\n}\n\nconst HTML_NS = 'http://www.w3.org/1999/xhtml';\n\n/** Only an HTML `<template>` has a content fragment; `<svg><template>` is a plain element. */\nfunction templateContent(el: Element): DocumentFragment | null {\n return elementLocalName(el) === 'template' && elementNamespace(el) === HTML_NS ? templateContentOf(el) : null;\n}\n\n/**\n * A spec `<template>` keeps its parsed nodes in `content` and has no\n * children. linkedom keeps them as the template's children, which is what it\n * serializes, and fills `content` with a copy when it is first read: sanitize\n * both.\n */\nfunction sanitizeTemplate(el: Element, content: DocumentFragment = templateContentOf(el)): void {\n sanitizeNode(content);\n sanitizeNode(el);\n}\n\nfunction sanitizeNode(root: ParentNode): void {\n // Snapshot before mutating: removing from a live collection while iterating it skips the next sibling.\n for (const el of childrenOf(root)) {\n const tag = elementLocalName(el).toLowerCase();\n if (STRIPPED_TAGS.has(tag) || animatesUrlAttribute(el, tag)) {\n invoke(el, 'remove');\n continue;\n }\n for (const attr of Array.from(elementAttributes(el))) {\n const name = attr.name.toLowerCase();\n if (\n !isAllowedAttribute(name, attr.value) ||\n (FRAME_TAGS.has(tag) && FRAME_URL_ATTRS.has(name) && isDangerousUrl(attr.value, SCRIPT_OR_DATA_URL)) ||\n (CLOBBERING_ATTRS.has(name) && clobbers(attr.value))\n ) {\n invoke(el, 'removeAttribute', attr.name);\n }\n }\n const content = templateContent(el);\n if (content) sanitizeTemplate(el, content);\n else sanitizeNode(el);\n }\n}\n\nfunction animatesUrlAttribute(el: Element, tag: string): boolean {\n if (!ATTR_ANIMATION_TAGS.has(tag)) return false;\n const target = (invoke<string | null>(el, 'getAttribute', 'attributeName') ?? '').trim().toLowerCase();\n return URL_ATTRS.has(target) || URL_ATTRS.has(target.replace(/^xlink:/, ''));\n}\n\nfunction isDangerousUrl(value: string, schemes: RegExp): boolean {\n // Browsers strip ASCII tab/newline/CR from a URL (and trim leading C0\n // control/space) before sniffing the scheme, so \"java\\tscript:\" still runs\n // as javascript: — normalize the same way before checking it.\n return schemes.test(value.replace(/[\\t\\n\\r]/g, '').replace(/^[\\x00-\\x20]+/, ''));\n}\n","import { nodeChildNodes, parseInContext, parseSanitized, sanitizeMarkup } from './sanitize.js';\nimport { isTrustedHTML, type TrustedHTML } from './trusted-types.js';\n\n/**\n * Markup to insert as HTML rather than as text: made by `raw()` (sanitized)\n * or `trustedRaw()` (as is). Anywhere this library takes content — a `h()`\n * child, a snackbar/banner/`confirmDialog()` message — a plain string is text\n * and a `Raw` is markup, parsed in the context of the element it goes into.\n *\n * Only values made by `raw()`/`trustedRaw()` count: a plain object with an\n * `__html` key (e.g. parsed JSON) is inserted as text like any other value.\n *\n * `__html` and `String()` give the markup as a string (sanitized for\n * `raw()`), which the browser parses a second time when it is assigned to\n * `innerHTML`; inserting it as content parses it only once.\n */\nexport interface Raw {\n readonly __html: string;\n toString(): string;\n}\n\n/**\n * Brands, through `Symbol.for` rather than module-local symbols: a page can\n * hold more than one copy of this module, and markup made through one copy\n * must stay recognized in another. The `dist/browser` entries share a single\n * copy (code splitting puts it in one chunk), but `dist/core` loaded\n * alongside `dist/browser`, or two versions of the package, are two.\n */\nconst RAW: unique symbol = Symbol.for('a11y-elements/raw');\n/** The markup as given, always a string: copies of the library before 1.1 read it, and sanitize anything else. */\nconst SOURCE: unique symbol = Symbol.for('a11y-elements/raw-source');\n/** Set by `trustedRaw()` when given a `TrustedHTML`: what is written to the sink. 1.1+ only. */\nconst TRUSTED_HTML: unique symbol = Symbol.for('a11y-elements/raw-trusted-html');\n/** Set by `trustedRaw()`: insert unsanitized. */\nconst TRUSTED: unique symbol = Symbol.for('a11y-elements/raw-trusted');\n\nclass Markup implements Raw {\n readonly [RAW] = true;\n readonly [SOURCE]: string;\n readonly [TRUSTED]: boolean;\n readonly [TRUSTED_HTML]?: TrustedHTML;\n\n constructor(source: string, trusted: boolean, trustedHtml?: TrustedHTML) {\n this[SOURCE] = source;\n this[TRUSTED] = trusted;\n if (trustedHtml) this[TRUSTED_HTML] = trustedHtml;\n }\n\n get __html(): string {\n return this.toString();\n }\n\n toString(): string {\n return this[TRUSTED] ? this[SOURCE] : sanitizeMarkup(this[SOURCE]);\n }\n}\n\n/**\n * Markup inserted sanitized: `<script>`, `<style>`, `<link>`, `<base>`,\n * `<meta>`, event handler attributes, `srcdoc`, `javascript:` URLs, `data:`\n * frame sources and SVG animations of URL attributes are removed, and so is\n * an `id`/`name` that would shadow a built-in of `document` or of a `<form>`\n * (`name=\"createElement\"`, `name=\"action\"`, `id=\"body\"`, …).\n */\nexport function raw(value: string): Raw {\n return new Markup(value == null ? '' : String(value), false);\n}\n\n/**\n * Markup inserted exactly as given, unsanitized. Only for markup you wrote\n * yourself — never for anything user input can reach.\n *\n * Under a Trusted Types CSP (`require-trusted-types-for 'script'`) pass a\n * `TrustedHTML` made by your own policy: a plain string is rejected by the\n * browser when it is inserted. The library's `a11y-elements` policy only\n * covers `raw()`, which it sanitizes.\n */\nexport function trustedRaw(value: string | TrustedHTML): Raw {\n if (isTrustedHTML(value)) return new Markup(String(value), true, value);\n return new Markup(value == null ? '' : String(value), true);\n}\n\nexport function isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && (value as Record<symbol, unknown>)[RAW] === true;\n}\n\n/**\n * Parses `value` with `parent` as context and returns its nodes, sanitized\n * unless it came from `trustedRaw()`. Markup from an older bundle (no\n * `SOURCE`, e.g. an `html` result) is its `__html`, sanitized.\n */\nexport function rawNodes(value: Raw, parent: Node | null): Node[] {\n const brand = value as unknown as Record<symbol, unknown>;\n const source = brand[SOURCE];\n if (typeof source !== 'string') return parseSanitized(value.__html, parent);\n if (brand[TRUSTED] === true) {\n const trustedHtml = brand[TRUSTED_HTML];\n return Array.from(nodeChildNodes(parseInContext(isTrustedHTML(trustedHtml) ? trustedHtml : source, parent)));\n }\n return parseSanitized(source, parent);\n}\n","import { isRaw, rawNodes, type Raw } from './template.js';\nimport { call, doc } from './safe-dom.js';\n\n/** Content for an element: a string is text, a `Raw` is markup (see `raw()`), a `Node` goes in as is. */\nexport type Content = string | number | Node | Raw;\n\n/** A `h()` child or `appendContent()` item: `null`/`undefined`/`false` add nothing, so `cond && h(…)` works inline. */\nexport type Child = Content | null | undefined | false;\n\n/** An attribute value: `true` sets it bare (`disabled`), `null`/`undefined`/`false` leave it out, anything else is stringified. */\nexport type AttrValue = string | number | boolean | null | undefined;\n\n/**\n * Appends `children` to `parent`, in order. Strings and numbers become text\n * nodes (never parsed), a `Raw` is parsed with `parent` as context.\n */\nexport function appendContent(parent: ParentNode & Node, ...children: Child[]): void {\n for (const child of children) {\n if (child == null || child === false) continue;\n // `call()`: `parent` can be a <form> whose controls shadow `append`.\n if (isRaw(child)) call(parent, 'append', ...rawNodes(child, parent));\n else if (typeof child === 'object' && 'nodeType' in child) call(parent, 'append', child);\n else call(parent, 'append', String(child));\n }\n}\n\n/**\n * Creates an element node by node — the safe counterpart of building markup\n * as a string: values are set with `setAttribute()` and inserted as text, so\n * nothing in them is ever parsed as HTML.\n *\n * `` h('button', { type: 'button', class: 'x', disabled: busy }, label) ``\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs?: Record<string, AttrValue> | null,\n ...children: Child[]\n): HTMLElementTagNameMap[K];\nexport function h(tag: string, attrs?: Record<string, AttrValue> | null, ...children: Child[]): HTMLElement;\nexport function h(tag: string, attrs?: Record<string, AttrValue> | null, ...children: Child[]): HTMLElement {\n const el = doc.createElement(tag);\n setAttrs(el, attrs);\n appendContent(el, ...children);\n return el;\n}\n\n/** Sets each attribute of `attrs` on `el` — `true` bare — and removes those that are `null`/`undefined`/`false`. */\nexport function setAttrs(el: Element, attrs?: Record<string, AttrValue> | null): void {\n if (!attrs) return;\n for (const [name, value] of Object.entries(attrs)) {\n if (value == null || value === false) el.removeAttribute(name);\n else el.setAttribute(name, value === true ? '' : String(value));\n }\n}\n"],"mappings":";;;;;;;AAuBO,IAAM,cAAc;AAwB3B,SAAS,UAA2C;AAClD,QAAM,KAAM,WAA+D;AAC3E,SAAO,MAAM,OAAO,GAAG,iBAAiB,cAAc,OAAO,GAAG,WAAW,aAAc,KAA6B;AACxH;AAQA,SAAS,WAAoB;AAC3B,MAAI;AACF,QAAI,cAAc,UAAU,EAAE,YAAY;AAC1C,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,cAAc,OAAsC;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,QAAQ,GAAG,OAAO,KAAK,MAAM;AACrF;AAEA,IAAI;AACJ,IAAI,SAAS;AAEb,SAAS,YAAoC;AAC3C,MAAI,UAAU,OAAQ,QAAO;AAC7B,QAAM,KAAK,QAAQ;AACnB,MAAI,CAAC,GAAI,QAAO;AAChB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S,QAAQ,UAAU,MAAO;AAEtC,QAAI,MAAM,KAAK,EAAG,MAAK,QAAQ,UAAU,GAAG,SAAS,OAAO,MAAM,CAAC;AAAA,aAC1D,OAAO,UAAU,YAAY,cAAc,MAAO,MAAK,QAAQ,UAAU,KAAK;AAAA,QAClF,MAAK,QAAQ,UAAU,OAAO,KAAK,CAAC;AAAA,EAC3C;AACF;AAeO,SAAS,EAAE,KAAa,UAA6C,UAAgC;AAC1G,QAAM,KAAK,IAAI,cAAc,GAAG;AAChC,WAAS,IAAI,KAAK;AAClB,gBAAc,IAAI,GAAG,QAAQ;AAC7B,SAAO;AACT;AAGO,SAAS,SAAS,IAAa,OAAgD;AACpF,MAAI,CAAC,MAAO;AACZ,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AACjD,QAAI,SAAS,QAAQ,UAAU,MAAO,IAAG,gBAAgB,IAAI;AAAA,QACxD,IAAG,aAAa,MAAM,UAAU,OAAO,KAAK,OAAO,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  h
3
- } from "./chunk-KVUJT6BC.js";
3
+ } from "./chunk-7FIT24VV.js";
4
4
  import {
5
5
  A11yElement,
6
6
  defineElement,
@@ -72,4 +72,4 @@ defineElement("a11y-spinner", SpinnerElement);
72
72
  export {
73
73
  SpinnerElement
74
74
  };
75
- //# sourceMappingURL=chunk-NT7DOWM7.js.map
75
+ //# sourceMappingURL=chunk-CDDBLEN6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  h
3
- } from "./chunk-KVUJT6BC.js";
3
+ } from "./chunk-7FIT24VV.js";
4
4
  import {
5
5
  A11yElement,
6
6
  defineElement
@@ -47,4 +47,4 @@ defineElement("a11y-skeleton", SkeletonElement);
47
47
  export {
48
48
  SkeletonElement
49
49
  };
50
- //# sourceMappingURL=chunk-GA3VPLST.js.map
50
+ //# sourceMappingURL=chunk-GNAF4MSU.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  appendContent,
6
6
  h
7
- } from "./chunk-KVUJT6BC.js";
7
+ } from "./chunk-7FIT24VV.js";
8
8
  import {
9
9
  call,
10
10
  defineElement,
@@ -88,4 +88,4 @@ export {
88
88
  ModalElement,
89
89
  confirmDialog
90
90
  };
91
- //# sourceMappingURL=chunk-2HQKZFJV.js.map
91
+ //# sourceMappingURL=chunk-ONS5T35N.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-YYYJ6D77.js";
5
5
  import {
6
6
  h
7
- } from "./chunk-KVUJT6BC.js";
7
+ } from "./chunk-7FIT24VV.js";
8
8
  import {
9
9
  defineElement,
10
10
  doc,
@@ -137,4 +137,4 @@ export {
137
137
  SnackbarElement,
138
138
  notify
139
139
  };
140
- //# sourceMappingURL=chunk-GYM3EIL3.js.map
140
+ //# sourceMappingURL=chunk-RKZNZKLG.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-YYYJ6D77.js";
4
4
  import {
5
5
  h
6
- } from "./chunk-KVUJT6BC.js";
6
+ } from "./chunk-7FIT24VV.js";
7
7
  import {
8
8
  defineElement,
9
9
  doc,
@@ -128,4 +128,4 @@ export {
128
128
  NotificationBannerElement,
129
129
  showNotificationBanner
130
130
  };
131
- //# sourceMappingURL=chunk-HJUKOWFZ.js.map
131
+ //# sourceMappingURL=chunk-TU4BZYED.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AvatarElement
3
- } from "../../chunk-7CL7TH7I.js";
4
- import "../../chunk-KVUJT6BC.js";
3
+ } from "../../chunk-4ER4RFUO.js";
4
+ import "../../chunk-7FIT24VV.js";
5
5
  import {
6
6
  resetStrings,
7
7
  setStrings
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ProgressElement
3
- } from "../../chunk-MIBUA46B.js";
4
- import "../../chunk-KVUJT6BC.js";
3
+ } from "../../chunk-6HI2FNGK.js";
4
+ import "../../chunk-7FIT24VV.js";
5
5
  import "../../chunk-Q4TMA3P7.js";
6
6
  import {
7
7
  resetStrings,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SkeletonElement
3
- } from "../../chunk-GA3VPLST.js";
4
- import "../../chunk-KVUJT6BC.js";
3
+ } from "../../chunk-GNAF4MSU.js";
4
+ import "../../chunk-7FIT24VV.js";
5
5
  import {
6
6
  resetStrings,
7
7
  setStrings
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SpinnerElement
3
- } from "../../chunk-NT7DOWM7.js";
4
- import "../../chunk-KVUJT6BC.js";
3
+ } from "../../chunk-CDDBLEN6.js";
4
+ import "../../chunk-7FIT24VV.js";
5
5
  import {
6
6
  resetStrings,
7
7
  setStrings
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  BlockingLoaderElement
3
- } from "../../chunk-OB2NQV77.js";
3
+ } from "../../chunk-3QCORK3F.js";
4
4
  import "../../chunk-IJ6JK2XW.js";
5
5
  import "../../chunk-FNILKXCO.js";
6
6
  import {
7
7
  dismissAllOverlays,
8
8
  removeOverlaysWithin
9
9
  } from "../../chunk-H25W66MH.js";
10
- import "../../chunk-NT7DOWM7.js";
11
- import "../../chunk-KVUJT6BC.js";
10
+ import "../../chunk-CDDBLEN6.js";
11
+ import "../../chunk-7FIT24VV.js";
12
12
  import {
13
13
  resetStrings,
14
14
  setStrings
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ModalElement,
3
3
  confirmDialog
4
- } from "../../chunk-2HQKZFJV.js";
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-KVUJT6BC.js";
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-HJUKOWFZ.js";
4
+ } from "../../chunk-TU4BZYED.js";
5
5
  import "../../chunk-YYYJ6D77.js";
6
6
  import {
7
7
  dismissAllOverlays,
8
8
  removeOverlaysWithin
9
9
  } from "../../chunk-H25W66MH.js";
10
- import "../../chunk-KVUJT6BC.js";
10
+ import "../../chunk-7FIT24VV.js";
11
11
  import {
12
12
  resetStrings,
13
13
  setStrings
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  SnackbarElement,
3
3
  notify
4
- } from "../../chunk-GYM3EIL3.js";
4
+ } from "../../chunk-RKZNZKLG.js";
5
5
  import "../../chunk-YYYJ6D77.js";
6
6
  import {
7
7
  dismissAllOverlays,
8
8
  removeOverlaysWithin
9
9
  } from "../../chunk-H25W66MH.js";
10
- import "../../chunk-KVUJT6BC.js";
10
+ import "../../chunk-7FIT24VV.js";
11
11
  import {
12
12
  resetStrings,
13
13
  setStrings
@@ -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
- /** Parses `source` as markup with an element like `parent` as context, unsanitized: the holder of the parsed nodes. */
11
- export declare function parseInContext(source: string, parent: Node | null): ParentNode;
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;
@@ -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.innerHTML = source;
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
- /** Parses `source` as markup with an element like `parent` as context, unsanitized: the holder of the parsed nodes. */
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.innerHTML = source;
96
+ setHTML(context, source);
92
97
  return context;
93
98
  }
94
- holder.innerHTML = source;
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;AAEpC;;;;;;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;AAC1E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AACjD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;AAEzG,wHAAwH;AACxH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;AAExD,MAAM,UAAU,GAAG,eAAe,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AACjD,IAAI,SAAsC,CAAC;AAE3C,SAAS,QAAQ,CAAC,KAAa;IAC7B,SAAS,KAAK,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,KAAK,IAAI,QAAQ,IAAI,KAAK,IAAI,S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,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,MAAM,MAAM,GAAG,CAAC,MAAM,CAAgB,EAAE,EAAE,cAAc,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACvG,OAAO,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,OAAe;IACpD,sEAAsE;IACtE,2EAA2E;IAC3E,8DAA8D;IAC9D,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;AACnF,CAAC"}
@@ -1,3 +1,4 @@
1
+ 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
- /** Markup inserted exactly as given, unsanitized. Only for markup you wrote yourself — never for anything user input can reach. */
27
- export declare function trustedRaw(value: string): Raw;
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
@@ -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: each
4
- * standalone `dist/browser/**\/define.js` bundle inlines its own copy of this
5
- * module, and markup made through one bundle must stay recognized in another.
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
- constructor(source, trusted) {
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
- /** Markup inserted exactly as given, unsanitized. Only for markup you wrote yourself — never for anything user input can reach. */
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
- return Array.from(nodeChildNodes(parseInContext(source, parent)));
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;AAoB/F;;;;GAIG;AACH,MAAM,GAAG,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC3D,2BAA2B;AAC3B,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AACrE,iDAAiD;AACjD,MAAM,OAAO,GAAkB,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAEvE,MAAM,MAAM;IACD,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACb,CAAC,MAAM,CAAC,CAAS;IACjB,CAAC,OAAO,CAAC,CAAU;IAE5B,YAAY,MAAc,EAAE,OAAgB;QAC1C,IAAI,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AAC,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,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,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": "1.1.0",
4
4
  "description": "Framework-agnostic accessibility Custom Elements (Web Components) — behavior, not a themed UI kit.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/sanitize.ts","../../src/core/template.ts","../../src/core/dom.ts"],"sourcesContent":["import { builtIn } from './builtin.js';\nimport { doc } from './safe-dom.js';\n\n/**\n * DOM-based sanitizer behind `raw()`: markup is parsed once in the inert\n * document behind a `<template>` (nothing loads or runs there), cleaned as\n * nodes, and those nodes are what gets inserted — never re-serialized and\n * parsed again, which is where mutation XSS turns inert text back into\n * elements.\n */\n\n/** Compared against `localName`, so SVG/MathML elements of the same name are caught too. style/link restyle the page, base moves every relative URL, meta can refresh/navigate. */\nconst STRIPPED_TAGS = new Set(['script', 'style', 'link', 'base', 'meta']);\n\n/** A `data:` document in a frame runs its own scripts (opaque origin). */\nconst FRAME_TAGS = new Set(['iframe', 'object', 'embed', 'frame']);\nconst FRAME_URL_ATTRS = new Set(['src', 'data']);\nconst URL_ATTRS = new Set(['href', 'src', 'action', 'formaction', 'poster', 'background', 'xlink:href']);\n\n/** SVG `<animate>`/`<set>` can rewrite an attribute after sanitization: those targeting a URL attribute are dropped. */\nconst ATTR_ANIMATION_TAGS = new Set(['animate', 'set']);\n\nconst SCRIPT_URL = /^javascript:/i;\n\n/**\n * `document` and `<form>` are `[LegacyOverrideBuiltIns]` too: once inserted,\n * `<img name=\"createElement\">` makes `document.createElement` that image, and\n * `<input name=\"action\">` shadows its form's `action`. An `id`/`name` whose\n * value names a property of either (or of a named element already on the\n * page) is dropped — DOMPurify's `SANITIZE_DOM`. Markup you write yourself,\n * or pass to `trustedRaw()`, keeps its names.\n */\nconst CLOBBERING_ATTRS = new Set(['id', 'name']);\nlet probeForm: HTMLFormElement | undefined;\n\nfunction clobbers(value: string): boolean {\n probeForm ??= doc.createElement('form');\n return value in document || value in probeForm;\n}\n\n/*\n * Clobbering-proof DOM access. A `<form>` is `[LegacyOverrideBuiltIns]`: a\n * descendant named `children`, `attributes`, `localName`, `remove`, … shadows\n * that property on the form itself, so reading `form.children` straight off\n * the element can return an attacker's `<img>` and make the walk skip it.\n * Every read below goes through the node's prototype chain instead (named\n * properties are own properties of the instance, never on a prototype).\n *\n * Resolved on each call, never captured at load: importing this module needs\n * no DOM, and non-spec DOMs used for SSR work too — linkedom puts `children`\n * on a mixin, has a stub `childNodes` on `Node.prototype` that subclasses\n * override, and sets `nodeType`/`localName` as data on each node.\n */\nfunction read<T>(node: unknown, name: string): T {\n const desc = builtIn(node as object, name);\n if (desc) return (desc.get ? desc.get.call(node) : desc.value) as T;\n // No prototype has it (per-node data, as in linkedom). Never an own getter.\n return Object.getOwnPropertyDescriptor(node as object, name)?.value as T;\n}\n\nfunction invoke<T>(node: unknown, name: string, ...args: unknown[]): T {\n return (builtIn(node as object, name)!.value as (...a: unknown[]) => T).apply(node, args);\n}\n\nexport const nodeChildNodes = (node: unknown): NodeListOf<ChildNode> => read(node, 'childNodes');\nconst nodeType = (node: unknown): number => read(node, 'nodeType');\nconst elementChildren = (node: unknown): HTMLCollection => read(node, 'children');\nconst elementAttributes = (el: Element): NamedNodeMap => read(el, 'attributes');\nconst elementLocalName = (el: Element): string => read(el, 'localName');\nconst elementNamespace = (el: Element): string | null => read(el, 'namespaceURI');\nconst templateContentOf = (el: Element): DocumentFragment => read(el, 'content');\n\nconst ELEMENT_NODE = 1;\n\nfunction childrenOf(root: ParentNode): Element[] {\n return Array.from(elementChildren(root));\n}\nconst SCRIPT_OR_DATA_URL = /^(javascript|data):/i;\n\n/** Parses `source` as markup and returns it sanitized, as a string. Only for `String()` fallbacks: rendering inserts the nodes from `parseSanitized()` instead. */\nexport function sanitizeMarkup(source: string): string {\n const holder = doc.createElement('template');\n holder.innerHTML = source;\n sanitizeTemplate(holder);\n return holder.innerHTML;\n}\n\n/**\n * Parses `source` with an element like `parent` as context (so `<tr>`, SVG\n * or MathML content parses as it will once inserted under it), sanitizes it,\n * and returns the resulting nodes.\n */\nexport function parseSanitized(source: string, parent: Node | null): Node[] {\n const root = parseInContext(source, parent);\n sanitizeNode(root);\n return Array.from(nodeChildNodes(root));\n}\n\n/** Parses `source` as markup with an element like `parent` as context, unsanitized: the holder of the parsed nodes. */\nexport function parseInContext(source: string, parent: Node | null): ParentNode {\n const holder = doc.createElement('template');\n const parentEl = parent && nodeType(parent) === ELEMENT_NODE ? (parent as Element) : null;\n if (parentEl && !templateContent(parentEl)) {\n const context = holder.content.ownerDocument.createElementNS(elementNamespace(parentEl), elementLocalName(parentEl));\n context.innerHTML = source;\n return context;\n }\n holder.innerHTML = source;\n return holder.content;\n}\n\nfunction isAllowedAttribute(name: string, value: string): boolean {\n // srcdoc is parsed as a same-origin document: escaped markup in it is decoded and runs.\n if (name.startsWith('on') || name === 'srcdoc') return false;\n return !(URL_ATTRS.has(name) && isDangerousUrl(value, SCRIPT_URL));\n}\n\nconst HTML_NS = 'http://www.w3.org/1999/xhtml';\n\n/** Only an HTML `<template>` has a content fragment; `<svg><template>` is a plain element. */\nfunction templateContent(el: Element): DocumentFragment | null {\n return elementLocalName(el) === 'template' && elementNamespace(el) === HTML_NS ? templateContentOf(el) : null;\n}\n\n/**\n * A spec `<template>` keeps its parsed nodes in `content` and has no\n * children. linkedom keeps them as the template's children, which is what it\n * serializes, and fills `content` with a copy when it is first read: sanitize\n * both.\n */\nfunction sanitizeTemplate(el: Element, content: DocumentFragment = templateContentOf(el)): void {\n sanitizeNode(content);\n sanitizeNode(el);\n}\n\nfunction sanitizeNode(root: ParentNode): void {\n // Snapshot before mutating: removing from a live collection while iterating it skips the next sibling.\n for (const el of childrenOf(root)) {\n const tag = elementLocalName(el).toLowerCase();\n if (STRIPPED_TAGS.has(tag) || animatesUrlAttribute(el, tag)) {\n invoke(el, 'remove');\n continue;\n }\n for (const attr of Array.from(elementAttributes(el))) {\n const name = attr.name.toLowerCase();\n if (\n !isAllowedAttribute(name, attr.value) ||\n (FRAME_TAGS.has(tag) && FRAME_URL_ATTRS.has(name) && isDangerousUrl(attr.value, SCRIPT_OR_DATA_URL)) ||\n (CLOBBERING_ATTRS.has(name) && clobbers(attr.value))\n ) {\n invoke(el, 'removeAttribute', attr.name);\n }\n }\n const content = templateContent(el);\n if (content) sanitizeTemplate(el, content);\n else sanitizeNode(el);\n }\n}\n\nfunction animatesUrlAttribute(el: Element, tag: string): boolean {\n if (!ATTR_ANIMATION_TAGS.has(tag)) return false;\n const target = (invoke<string | null>(el, 'getAttribute', 'attributeName') ?? '').trim().toLowerCase();\n return URL_ATTRS.has(target) || URL_ATTRS.has(target.replace(/^xlink:/, ''));\n}\n\nfunction isDangerousUrl(value: string, schemes: RegExp): boolean {\n // Browsers strip ASCII tab/newline/CR from a URL (and trim leading C0\n // control/space) before sniffing the scheme, so \"java\\tscript:\" still runs\n // as javascript: — normalize the same way before checking it.\n return schemes.test(value.replace(/[\\t\\n\\r]/g, '').replace(/^[\\x00-\\x20]+/, ''));\n}\n","import { nodeChildNodes, parseInContext, parseSanitized, sanitizeMarkup } from './sanitize.js';\n\n/**\n * Markup to insert as HTML rather than as text: made by `raw()` (sanitized)\n * or `trustedRaw()` (as is). Anywhere this library takes content — a `h()`\n * child, a snackbar/banner/`confirmDialog()` message — a plain string is text\n * and a `Raw` is markup, parsed in the context of the element it goes into.\n *\n * Only values made by `raw()`/`trustedRaw()` count: a plain object with an\n * `__html` key (e.g. parsed JSON) is inserted as text like any other value.\n *\n * `__html` and `String()` give the markup as a string (sanitized for\n * `raw()`), which the browser parses a second time when it is assigned to\n * `innerHTML`; inserting it as content parses it only once.\n */\nexport interface Raw {\n readonly __html: string;\n toString(): string;\n}\n\n/**\n * Brands, through `Symbol.for` rather than module-local symbols: each\n * standalone `dist/browser/**\\/define.js` bundle inlines its own copy of this\n * module, and markup made through one bundle must stay recognized in another.\n */\nconst RAW: unique symbol = Symbol.for('a11y-elements/raw');\n/** The markup as given. */\nconst SOURCE: unique symbol = Symbol.for('a11y-elements/raw-source');\n/** Set by `trustedRaw()`: insert unsanitized. */\nconst TRUSTED: unique symbol = Symbol.for('a11y-elements/raw-trusted');\n\nclass Markup implements Raw {\n readonly [RAW] = true;\n readonly [SOURCE]: string;\n readonly [TRUSTED]: boolean;\n\n constructor(source: string, trusted: boolean) {\n this[SOURCE] = source;\n this[TRUSTED] = trusted;\n }\n\n get __html(): string {\n return this.toString();\n }\n\n toString(): string {\n return this[TRUSTED] ? this[SOURCE] : sanitizeMarkup(this[SOURCE]);\n }\n}\n\n/**\n * Markup inserted sanitized: `<script>`, `<style>`, `<link>`, `<base>`,\n * `<meta>`, event handler attributes, `srcdoc`, `javascript:` URLs, `data:`\n * frame sources and SVG animations of URL attributes are removed, and so is\n * an `id`/`name` that would shadow a built-in of `document` or of a `<form>`\n * (`name=\"createElement\"`, `name=\"action\"`, `id=\"body\"`, …).\n */\nexport function raw(value: string): Raw {\n return new Markup(value == null ? '' : String(value), false);\n}\n\n/** Markup inserted exactly as given, unsanitized. Only for markup you wrote yourself — never for anything user input can reach. */\nexport function trustedRaw(value: string): Raw {\n return new Markup(value == null ? '' : String(value), true);\n}\n\nexport function isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && (value as Record<symbol, unknown>)[RAW] === true;\n}\n\n/**\n * Parses `value` with `parent` as context and returns its nodes, sanitized\n * unless it came from `trustedRaw()`. Markup from an older bundle (no\n * `SOURCE`, e.g. an `html` result) is its `__html`, sanitized.\n */\nexport function rawNodes(value: Raw, parent: Node | null): Node[] {\n const brand = value as unknown as Record<symbol, unknown>;\n const source = brand[SOURCE];\n if (typeof source !== 'string') return parseSanitized(value.__html, parent);\n if (brand[TRUSTED] === true) return Array.from(nodeChildNodes(parseInContext(source, parent)));\n return parseSanitized(source, parent);\n}\n","import { isRaw, rawNodes, type Raw } from './template.js';\nimport { call, doc } from './safe-dom.js';\n\n/** Content for an element: a string is text, a `Raw` is markup (see `raw()`), a `Node` goes in as is. */\nexport type Content = string | number | Node | Raw;\n\n/** A `h()` child or `appendContent()` item: `null`/`undefined`/`false` add nothing, so `cond && h(…)` works inline. */\nexport type Child = Content | null | undefined | false;\n\n/** An attribute value: `true` sets it bare (`disabled`), `null`/`undefined`/`false` leave it out, anything else is stringified. */\nexport type AttrValue = string | number | boolean | null | undefined;\n\n/**\n * Appends `children` to `parent`, in order. Strings and numbers become text\n * nodes (never parsed), a `Raw` is parsed with `parent` as context.\n */\nexport function appendContent(parent: ParentNode & Node, ...children: Child[]): void {\n for (const child of children) {\n if (child == null || child === false) continue;\n // `call()`: `parent` can be a <form> whose controls shadow `append`.\n if (isRaw(child)) call(parent, 'append', ...rawNodes(child, parent));\n else if (typeof child === 'object' && 'nodeType' in child) call(parent, 'append', child);\n else call(parent, 'append', String(child));\n }\n}\n\n/**\n * Creates an element node by node — the safe counterpart of building markup\n * as a string: values are set with `setAttribute()` and inserted as text, so\n * nothing in them is ever parsed as HTML.\n *\n * `` h('button', { type: 'button', class: 'x', disabled: busy }, label) ``\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs?: Record<string, AttrValue> | null,\n ...children: Child[]\n): HTMLElementTagNameMap[K];\nexport function h(tag: string, attrs?: Record<string, AttrValue> | null, ...children: Child[]): HTMLElement;\nexport function h(tag: string, attrs?: Record<string, AttrValue> | null, ...children: Child[]): HTMLElement {\n const el = doc.createElement(tag);\n setAttrs(el, attrs);\n appendContent(el, ...children);\n return el;\n}\n\n/** Sets each attribute of `attrs` on `el` — `true` bare — and removes those that are `null`/`undefined`/`false`. */\nexport function setAttrs(el: Element, attrs?: Record<string, AttrValue> | null): void {\n if (!attrs) return;\n for (const [name, value] of Object.entries(attrs)) {\n if (value == null || value === false) el.removeAttribute(name);\n else el.setAttribute(name, value === true ? '' : String(value));\n }\n}\n"],"mappings":";;;;;;;AAYA,IAAM,gBAAgB,oBAAI,IAAI,CAAC,UAAU,SAAS,QAAQ,QAAQ,MAAM,CAAC;AAGzE,IAAM,aAAa,oBAAI,IAAI,CAAC,UAAU,UAAU,SAAS,OAAO,C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