@b9g/crank 0.7.2 → 0.7.4
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 +50 -31
- package/_css.cjs.map +1 -1
- package/_css.js.map +1 -1
- package/_utils.cjs.map +1 -1
- package/_utils.js.map +1 -1
- package/async.cjs.map +1 -1
- package/async.js.map +1 -1
- package/crank.cjs +47 -32
- package/crank.cjs.map +1 -1
- package/crank.d.ts +8 -0
- package/crank.js +47 -32
- package/crank.js.map +1 -1
- package/dom.cjs +75 -33
- package/dom.cjs.map +1 -1
- package/dom.d.ts +1 -1
- package/dom.js +75 -33
- package/dom.js.map +1 -1
- package/event-target.cjs.map +1 -1
- package/event-target.js.map +1 -1
- package/html.cjs +14 -0
- package/html.cjs.map +1 -1
- package/html.d.ts +10 -3
- package/html.js +14 -0
- package/html.js.map +1 -1
- package/jsx-runtime.js.map +1 -1
- package/jsx-tag.cjs.map +1 -1
- package/jsx-tag.js.map +1 -1
- package/package.json +1 -1
- package/umd.js +136 -65
- package/umd.js.map +1 -1
package/dom.cjs
CHANGED
|
@@ -5,6 +5,15 @@ var _css = require('./_css.cjs');
|
|
|
5
5
|
|
|
6
6
|
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
7
7
|
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
8
|
+
function getRootDocument(root) {
|
|
9
|
+
if (root && root.ownerDocument) {
|
|
10
|
+
return root.ownerDocument;
|
|
11
|
+
}
|
|
12
|
+
if (root && root.nodeType === Node.DOCUMENT_NODE) {
|
|
13
|
+
return root;
|
|
14
|
+
}
|
|
15
|
+
return document;
|
|
16
|
+
}
|
|
8
17
|
function isWritableProperty(element, name) {
|
|
9
18
|
// walk up the object's prototype chain to find the owner
|
|
10
19
|
let propOwner = element;
|
|
@@ -35,11 +44,18 @@ function emitHydrationWarning(propName, quietProps, expectedValue, actualValue,
|
|
|
35
44
|
else if (expectedValue === true || expectedValue === "") {
|
|
36
45
|
console.warn(`Expected "${showName}" to be ${expectedValue === true ? "present" : '""'} but found ${String(actualValue)} while hydrating:`, element);
|
|
37
46
|
}
|
|
38
|
-
else if (typeof window !== "undefined" &&
|
|
39
|
-
window.location &&
|
|
40
|
-
new URL(expectedValue, window.location.origin).href ===
|
|
41
|
-
new URL(actualValue, window.location.origin).href) ;
|
|
42
47
|
else {
|
|
48
|
+
// Check if this is a URL mismatch that's actually just resolution
|
|
49
|
+
const win = element.ownerDocument.defaultView;
|
|
50
|
+
if (win && win.location) {
|
|
51
|
+
const origin = win.location.origin;
|
|
52
|
+
if (new URL(expectedValue, origin).href ===
|
|
53
|
+
new URL(actualValue, origin).href) {
|
|
54
|
+
// attrs which are URLs will often be resolved to their full
|
|
55
|
+
// href in the DOM, so we squash these errors
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
43
59
|
console.warn(`Expected "${showName}" to be "${String(expectedValue)}" but found ${String(actualValue)} while hydrating:`, element);
|
|
44
60
|
}
|
|
45
61
|
}
|
|
@@ -60,7 +76,7 @@ const adapter = {
|
|
|
60
76
|
}
|
|
61
77
|
return props.xmlns || xmlns;
|
|
62
78
|
},
|
|
63
|
-
create({ tag, tagName, scope: xmlns, }) {
|
|
79
|
+
create({ tag, tagName, scope: xmlns, root, }) {
|
|
64
80
|
if (typeof tag !== "string") {
|
|
65
81
|
throw new Error(`Unknown tag: ${tagName}`);
|
|
66
82
|
}
|
|
@@ -70,18 +86,18 @@ const adapter = {
|
|
|
70
86
|
else if (tag.toLowerCase() === "math") {
|
|
71
87
|
xmlns = MATHML_NAMESPACE;
|
|
72
88
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
: document.createElement(tag);
|
|
89
|
+
const doc = getRootDocument(root);
|
|
90
|
+
return xmlns ? doc.createElementNS(xmlns, tag) : doc.createElement(tag);
|
|
76
91
|
},
|
|
77
|
-
adopt({ tag, tagName, node, }) {
|
|
92
|
+
adopt({ tag, tagName, node, root, }) {
|
|
78
93
|
if (typeof tag !== "string" && tag !== crank.Portal) {
|
|
79
94
|
throw new Error(`Unknown tag: ${tagName}`);
|
|
80
95
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
node ===
|
|
84
|
-
node ===
|
|
96
|
+
const doc = getRootDocument(root);
|
|
97
|
+
if (node === doc.body ||
|
|
98
|
+
node === doc.head ||
|
|
99
|
+
node === doc.documentElement ||
|
|
100
|
+
node === doc) {
|
|
85
101
|
console.warn(`Hydrating ${node.nodeName.toLowerCase()} is discouraged as it is destructive and may remove unknown nodes.`);
|
|
86
102
|
}
|
|
87
103
|
if (node == null ||
|
|
@@ -239,19 +255,28 @@ const adapter = {
|
|
|
239
255
|
const hydratingClassName = isHydrating
|
|
240
256
|
? element.getAttribute("class")
|
|
241
257
|
: undefined;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
shouldIssueWarning = true;
|
|
251
|
-
}
|
|
258
|
+
const allClassNames = { ...oldValue, ...value };
|
|
259
|
+
// Two passes: removes first, then adds. This ensures that
|
|
260
|
+
// overlapping classes in different keys are handled correctly.
|
|
261
|
+
// e.g. {"a b": false, "b c": true} should result in "b c"
|
|
262
|
+
for (const classNames in allClassNames) {
|
|
263
|
+
if (!(value && value[classNames])) {
|
|
264
|
+
const classes = classNames.split(/\s+/).filter(Boolean);
|
|
265
|
+
element.classList.remove(...classes);
|
|
252
266
|
}
|
|
253
|
-
|
|
254
|
-
|
|
267
|
+
}
|
|
268
|
+
for (const classNames in allClassNames) {
|
|
269
|
+
if (value && value[classNames]) {
|
|
270
|
+
const classes = classNames.split(/\s+/).filter(Boolean);
|
|
271
|
+
element.classList.add(...classes);
|
|
272
|
+
for (const className of classes) {
|
|
273
|
+
if (hydratingClasses && hydratingClasses.has(className)) {
|
|
274
|
+
hydratingClasses.delete(className);
|
|
275
|
+
}
|
|
276
|
+
else if (isHydrating) {
|
|
277
|
+
shouldIssueWarning = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
255
280
|
}
|
|
256
281
|
}
|
|
257
282
|
if (shouldIssueWarning ||
|
|
@@ -300,7 +325,22 @@ const adapter = {
|
|
|
300
325
|
!(typeof value === "string" &&
|
|
301
326
|
typeof element[name] === "boolean") &&
|
|
302
327
|
isWritableProperty(element, name)) {
|
|
303
|
-
|
|
328
|
+
// For URL properties like src and href, the DOM property returns the
|
|
329
|
+
// resolved absolute URL. We need to resolve the prop value the same way
|
|
330
|
+
// to compare correctly.
|
|
331
|
+
let domValue = element[name];
|
|
332
|
+
let propValue = value;
|
|
333
|
+
if ((name === "src" || name === "href") &&
|
|
334
|
+
typeof value === "string" &&
|
|
335
|
+
typeof domValue === "string") {
|
|
336
|
+
try {
|
|
337
|
+
propValue = new URL(value, element.baseURI).href;
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
// Invalid URL, use original value for comparison
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (propValue !== domValue || oldValue === undefined) {
|
|
304
344
|
if (isHydrating &&
|
|
305
345
|
typeof element[name] === "string" &&
|
|
306
346
|
element[name] !== value) {
|
|
@@ -363,7 +403,8 @@ const adapter = {
|
|
|
363
403
|
parentNode.removeChild(node);
|
|
364
404
|
}
|
|
365
405
|
},
|
|
366
|
-
text({ value, oldNode, hydrationNodes, }) {
|
|
406
|
+
text({ value, oldNode, hydrationNodes, root, }) {
|
|
407
|
+
const doc = getRootDocument(root);
|
|
367
408
|
if (hydrationNodes != null) {
|
|
368
409
|
let node = hydrationNodes.shift();
|
|
369
410
|
if (!node || node.nodeType !== Node.TEXT_NODE) {
|
|
@@ -377,7 +418,7 @@ const adapter = {
|
|
|
377
418
|
// the text node is longer than the expected text, so we
|
|
378
419
|
// reuse the existing text node, but truncate it and unshift the rest
|
|
379
420
|
node.data = value;
|
|
380
|
-
hydrationNodes.unshift(
|
|
421
|
+
hydrationNodes.unshift(doc.createTextNode(textData.slice(value.length)));
|
|
381
422
|
return node;
|
|
382
423
|
}
|
|
383
424
|
}
|
|
@@ -395,16 +436,17 @@ const adapter = {
|
|
|
395
436
|
}
|
|
396
437
|
return oldNode;
|
|
397
438
|
}
|
|
398
|
-
return
|
|
439
|
+
return doc.createTextNode(value);
|
|
399
440
|
},
|
|
400
|
-
raw({ value, scope: xmlns, hydrationNodes, }) {
|
|
441
|
+
raw({ value, scope: xmlns, hydrationNodes, root, }) {
|
|
401
442
|
let nodes;
|
|
402
443
|
if (typeof value === "string") {
|
|
444
|
+
const doc = getRootDocument(root);
|
|
403
445
|
const el = xmlns == null
|
|
404
|
-
?
|
|
446
|
+
? doc.createElement("div")
|
|
405
447
|
: xmlns === SVG_NAMESPACE
|
|
406
|
-
?
|
|
407
|
-
:
|
|
448
|
+
? doc.createElementNS(xmlns, "svg")
|
|
449
|
+
: doc.createElementNS(xmlns, "math");
|
|
408
450
|
el.innerHTML = value;
|
|
409
451
|
nodes = Array.from(el.childNodes);
|
|
410
452
|
}
|
package/dom.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.cjs","sources":["../src/dom.ts"],"sourcesContent":["import {\n\tChildren,\n\tContext,\n\tElementValue,\n\tPortal,\n\tRenderer,\n\tRenderAdapter,\n} from \"./crank.js\";\nimport {camelToKebabCase, formatStyleValue} from \"./_css.js\";\n\nconst SVG_NAMESPACE = \"http://www.w3.org/2000/svg\";\nconst MATHML_NAMESPACE = \"http://www.w3.org/1998/Math/MathML\";\n\nfunction isWritableProperty(element: Element, name: string): boolean {\n\t// walk up the object's prototype chain to find the owner\n\tlet propOwner = element;\n\tdo {\n\t\tif (Object.prototype.hasOwnProperty.call(propOwner, name)) {\n\t\t\tbreak;\n\t\t}\n\t} while ((propOwner = Object.getPrototypeOf(propOwner)));\n\n\tif (propOwner === null) {\n\t\treturn false;\n\t}\n\n\t// get the descriptor for the named property and check whether it implies\n\t// that the property is writable\n\tconst descriptor = Object.getOwnPropertyDescriptor(propOwner, name);\n\tif (\n\t\tdescriptor != null &&\n\t\t(descriptor.writable === true || descriptor.set !== undefined)\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction emitHydrationWarning(\n\tpropName: string,\n\tquietProps: Set<string> | undefined,\n\texpectedValue: any,\n\tactualValue: any,\n\telement: Element,\n\tdisplayName?: string,\n) {\n\tconst checkName = propName;\n\tconst showName = displayName || propName;\n\tif (!quietProps || !quietProps.has(checkName)) {\n\t\tif (expectedValue === null || expectedValue === false) {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be missing but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else if (expectedValue === true || expectedValue === \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be ${expectedValue === true ? \"present\" : '\"\"'} but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else if (\n\t\t\ttypeof window !== \"undefined\" &&\n\t\t\twindow.location &&\n\t\t\tnew URL(expectedValue, window.location.origin).href ===\n\t\t\t\tnew URL(actualValue, window.location.origin).href\n\t\t) {\n\t\t\t// attrs which are URLs will often be resolved to their full\n\t\t\t// href in the DOM, so we squash these errors\n\t\t} else {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be \"${String(expectedValue)}\" but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport const adapter: Partial<RenderAdapter<Node, string, Element>> = {\n\tscope({\n\t\tscope: xmlns,\n\t\ttag,\n\t\tprops,\n\t}: {\n\t\tscope: string | undefined;\n\t\ttag: string | symbol;\n\t\tprops: Record<string, any>;\n\t}): string | undefined {\n\t\tswitch (tag) {\n\t\t\tcase Portal:\n\t\t\t\t// TODO: read the namespace from the portal root element\n\t\t\t\txmlns = undefined;\n\t\t\t\tbreak;\n\t\t\tcase \"svg\":\n\t\t\t\txmlns = SVG_NAMESPACE;\n\t\t\t\tbreak;\n\t\t\tcase \"math\":\n\t\t\t\txmlns = MATHML_NAMESPACE;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn props.xmlns || xmlns;\n\t},\n\n\tcreate({\n\t\ttag,\n\t\ttagName,\n\t\tscope: xmlns,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tscope: string | undefined;\n\t}): Node {\n\t\tif (typeof tag !== \"string\") {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t} else if (tag.toLowerCase() === \"svg\") {\n\t\t\txmlns = SVG_NAMESPACE;\n\t\t} else if (tag.toLowerCase() === \"math\") {\n\t\t\txmlns = MATHML_NAMESPACE;\n\t\t}\n\n\t\treturn xmlns\n\t\t\t? document.createElementNS(xmlns, tag)\n\t\t\t: document.createElement(tag);\n\t},\n\n\tadopt({\n\t\ttag,\n\t\ttagName,\n\t\tnode,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tnode: Node | undefined;\n\t}): Array<Node> | undefined {\n\t\tif (typeof tag !== \"string\" && tag !== Portal) {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t}\n\n\t\tif (\n\t\t\tnode === document.body ||\n\t\t\tnode === document.head ||\n\t\t\tnode === document.documentElement ||\n\t\t\tnode === document\n\t\t) {\n\t\t\tconsole.warn(\n\t\t\t\t`Hydrating ${node.nodeName.toLowerCase()} is discouraged as it is destructive and may remove unknown nodes.`,\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tnode == null ||\n\t\t\t(typeof tag === \"string\" &&\n\t\t\t\t(node.nodeType !== Node.ELEMENT_NODE ||\n\t\t\t\t\ttag.toLowerCase() !== (node as Element).tagName.toLowerCase()))\n\t\t) {\n\t\t\tconsole.warn(`Expected <${tagName}> while hydrating but found: `, node);\n\t\t\treturn;\n\t\t}\n\n\t\treturn Array.from(node.childNodes);\n\t},\n\n\tpatch({\n\t\ttagName,\n\t\tnode,\n\t\tprops,\n\t\toldProps,\n\t\tscope: xmlns,\n\t\tcopyProps,\n\t\tquietProps,\n\t\tisHydrating,\n\t}: {\n\t\tnode: Node;\n\t\ttagName: string;\n\t\tprops: Record<string, any>;\n\t\toldProps: Record<string, any> | undefined;\n\t\tscope: string | undefined;\n\t\tcopyProps: Set<string> | undefined;\n\t\tquietProps: Set<string> | undefined;\n\t\tisHydrating: boolean;\n\t}): void {\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) {\n\t\t\tthrow new TypeError(`Cannot patch node: ${String(node)}`);\n\t\t} else if (props.class && props.className) {\n\t\t\tconsole.error(\n\t\t\t\t`Both \"class\" and \"className\" set in props for <${tagName}>. Use one or the other.`,\n\t\t\t);\n\t\t}\n\n\t\tconst element = node as Element;\n\t\tconst isSVG = xmlns === SVG_NAMESPACE;\n\t\tconst isMathML = xmlns === MATHML_NAMESPACE;\n\t\tfor (let name in {...oldProps, ...props}) {\n\t\t\tlet value = props[name];\n\t\t\tconst oldValue = oldProps ? oldProps[name] : undefined;\n\t\t\t{\n\t\t\t\tif (copyProps != null && copyProps.has(name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// handle prop:name or attr:name properties\n\t\t\t\tconst colonIndex = name.indexOf(\":\");\n\t\t\t\tif (colonIndex !== -1) {\n\t\t\t\t\tconst [ns, name1] = [\n\t\t\t\t\t\tname.slice(0, colonIndex),\n\t\t\t\t\t\tname.slice(colonIndex + 1),\n\t\t\t\t\t];\n\t\t\t\t\tswitch (ns) {\n\t\t\t\t\t\tcase \"prop\":\n\t\t\t\t\t\t\t(node as any)[name1] = value;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase \"attr\":\n\t\t\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.removeAttribute(name1);\n\t\t\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\t\t\tif (isHydrating && !element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(name, quietProps, value, null, element);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.setAttribute(name1, \"\");\n\t\t\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (isHydrating && element.getAttribute(name1) !== value) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\telement.setAttribute(name1, String(value));\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (name) {\n\t\t\t\t// TODO: fix hydration warnings for the style prop\n\t\t\t\tcase \"style\": {\n\t\t\t\t\tconst style = (element as HTMLElement | SVGElement).style;\n\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.removeAttribute(\"style\");\n\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"style\", \"\");\n\t\t\t\t\t} else if (typeof value === \"string\") {\n\t\t\t\t\t\tif (style.cssText !== value) {\n\t\t\t\t\t\t\t// TODO: Fix hydration warnings for styles\n\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t//\t\tvalue,\n\t\t\t\t\t\t\t//\t\tstyle.cssText,\n\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t//}\n\n\t\t\t\t\t\t\tstyle.cssText = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear the style\n\t\t\t\t\t\t\t// TODO: only clear the styles enumerated in the old value\n\t\t\t\t\t\t\tstyle.cssText = \"\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const styleName in {...oldValue, ...value}) {\n\t\t\t\t\t\t\tconst cssName = camelToKebabCase(styleName);\n\t\t\t\t\t\t\tconst styleValue = value && (value as any)[styleName];\n\t\t\t\t\t\t\tif (styleValue == null) {\n\t\t\t\t\t\t\t\tif (isHydrating && style.getPropertyValue(cssName) !== \"\") {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstyle.removeProperty(cssName);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst formattedValue = formatStyleValue(cssName, styleValue);\n\t\t\t\t\t\t\t\tif (style.getPropertyValue(cssName) !== formattedValue) {\n\t\t\t\t\t\t\t\t\t// TODO: hydration warnings for style props\n\t\t\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t\t\t//\t\tformattedValue,\n\t\t\t\t\t\t\t\t\t//\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t\t\t//\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t\t\t//}\n\t\t\t\t\t\t\t\t\tstyle.setProperty(cssName, formattedValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"class\":\n\t\t\t\tcase \"className\":\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tif (isHydrating && element.getAttribute(\"class\") !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t} else if (value == null) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(\"class\")) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(\"class\");\n\t\t\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\t\t\t// class={{\"included-class\": true, \"excluded-class\": false}} syntax\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear all classes\n\t\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet shouldIssueWarning = false;\n\t\t\t\t\t\tconst hydratingClasses = isHydrating\n\t\t\t\t\t\t\t? new Set(Array.from(element.classList))\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tconst hydratingClassName = isHydrating\n\t\t\t\t\t\t\t? element.getAttribute(\"class\")\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\tfor (const className in {...oldValue, ...value}) {\n\t\t\t\t\t\t\tconst classValue = value && value[className];\n\t\t\t\t\t\t\tif (classValue) {\n\t\t\t\t\t\t\t\telement.classList.add(className);\n\t\t\t\t\t\t\t\tif (hydratingClasses && hydratingClasses.has(className)) {\n\t\t\t\t\t\t\t\t\thydratingClasses.delete(className);\n\t\t\t\t\t\t\t\t} else if (isHydrating) {\n\t\t\t\t\t\t\t\t\tshouldIssueWarning = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\telement.classList.remove(className);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldIssueWarning ||\n\t\t\t\t\t\t\t(hydratingClasses && hydratingClasses.size > 0)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tObject.keys(value)\n\t\t\t\t\t\t\t\t\t.filter((k) => value[k])\n\t\t\t\t\t\t\t\t\t.join(\" \"),\n\t\t\t\t\t\t\t\thydratingClassName || \"\",\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!isSVG && !isMathML) {\n\t\t\t\t\t\tif (element.className !== value) {\n\t\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.className,\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telement.className = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (element.getAttribute(\"class\") !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", value as string);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"innerHTML\":\n\t\t\t\t\tif (value !== oldValue) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.innerHTML,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.innerHTML = value as any;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tname[0] === \"o\" &&\n\t\t\t\t\t\tname[1] === \"n\" &&\n\t\t\t\t\t\tname[2] === name[2].toUpperCase() &&\n\t\t\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Support React-style event names (onClick, onChange, etc.)\n\t\t\t\t\t\tname = name.toLowerCase();\n\t\t\t\t\t}\n\n\t\t\t\t\t// try to set the property directly\n\t\t\t\t\tif (\n\t\t\t\t\t\tname in element &&\n\t\t\t\t\t\t// boolean properties will coerce strings, but sometimes they map to\n\t\t\t\t\t\t// enumerated attributes, where truthy strings (\"false\", \"no\") map to\n\t\t\t\t\t\t// falsy properties, so we force using setAttribute.\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\t\ttypeof (element as any)[name] === \"boolean\"\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tisWritableProperty(element, name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ((element as any)[name] !== value || oldValue === undefined) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisHydrating &&\n\t\t\t\t\t\t\t\ttypeof (element as any)[name] === \"string\" &&\n\t\t\t\t\t\t\t\t(element as any)[name] !== value\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t(element as any)[name],\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// if the property is writable, assign it directly\n\t\t\t\t\t\t\t(element as any)[name] = value;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tvalue = \"\";\n\t\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name)) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(name);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (element.getAttribute(name) !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.setAttribute(name, value as any);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tarrange({\n\t\ttag,\n\t\tnode,\n\t\tprops,\n\t\tchildren,\n\t}: {\n\t\ttag: string | symbol;\n\t\tnode: Node;\n\t\tprops: Record<string, any>;\n\t\tchildren: Array<Node>;\n\t}): void {\n\t\tif (tag === Portal && (node == null || typeof node.nodeType !== \"number\")) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`<Portal> root is not a node. Received: ${String(node)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"innerHTML\" in props)) {\n\t\t\tlet oldChild = node.firstChild;\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tconst newChild = children[i];\n\t\t\t\tif (oldChild === newChild) {\n\t\t\t\t\t// the child is already in the right place, so we can skip it\n\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t} else {\n\t\t\t\t\tnode.insertBefore(newChild, oldChild);\n\t\t\t\t\tif (\n\t\t\t\t\t\ttag !== Portal &&\n\t\t\t\t\t\toldChild &&\n\t\t\t\t\t\ti + 1 < children.length &&\n\t\t\t\t\t\toldChild !== children[i + 1]\n\t\t\t\t\t) {\n\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tremove({\n\t\tnode,\n\t\tparentNode,\n\t\tisNested,\n\t}: {\n\t\tnode: Node;\n\t\tparentNode: Node;\n\t\tisNested: boolean;\n\t}): void {\n\t\tif (!isNested && node.parentNode === parentNode) {\n\t\t\tparentNode.removeChild(node);\n\t\t}\n\t},\n\n\ttext({\n\t\tvalue,\n\t\toldNode,\n\t\thydrationNodes,\n\t}: {\n\t\tvalue: string;\n\t\thydrationNodes: Array<Node> | undefined;\n\t\toldNode: Node | undefined;\n\t}): Node {\n\t\tif (hydrationNodes != null) {\n\t\t\tlet node = hydrationNodes.shift();\n\t\t\tif (!node || node.nodeType !== Node.TEXT_NODE) {\n\t\t\t\tconsole.warn(`Expected \"${value}\" while hydrating but found:`, node);\n\t\t\t} else {\n\t\t\t\t// value is a text node, check if it matches the expected text\n\t\t\t\tconst textData = (node as Text).data;\n\t\t\t\tif (textData.length > value.length) {\n\t\t\t\t\tif (textData.startsWith(value)) {\n\t\t\t\t\t\t// the text node is longer than the expected text, so we\n\t\t\t\t\t\t// reuse the existing text node, but truncate it and unshift the rest\n\t\t\t\t\t\t(node as Text).data = value;\n\t\t\t\t\t\thydrationNodes.unshift(\n\t\t\t\t\t\t\tdocument.createTextNode(textData.slice(value.length)),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn node;\n\t\t\t\t\t}\n\t\t\t\t} else if (textData === value) {\n\t\t\t\t\treturn node;\n\t\t\t\t}\n\n\t\t\t\t// We log textData and not node because node will be mutated\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Expected \"${value}\" while hydrating but found:`,\n\t\t\t\t\ttextData,\n\t\t\t\t);\n\t\t\t\toldNode = node;\n\t\t\t}\n\t\t}\n\n\t\tif (oldNode != null) {\n\t\t\tif ((oldNode as Text).data !== value) {\n\t\t\t\t(oldNode as Text).data = value;\n\t\t\t}\n\n\t\t\treturn oldNode;\n\t\t}\n\n\t\treturn document.createTextNode(value);\n\t},\n\n\traw({\n\t\tvalue,\n\t\tscope: xmlns,\n\t\thydrationNodes,\n\t}: {\n\t\tvalue: string | Node;\n\t\tscope: string | undefined;\n\t\thydrationNodes: Array<Node> | undefined;\n\t}): ElementValue<Node> {\n\t\tlet nodes: Array<Node>;\n\t\tif (typeof value === \"string\") {\n\t\t\tconst el =\n\t\t\t\txmlns == null\n\t\t\t\t\t? document.createElement(\"div\")\n\t\t\t\t\t: xmlns === SVG_NAMESPACE\n\t\t\t\t\t\t? document.createElementNS(xmlns, \"svg\")\n\t\t\t\t\t\t: document.createElementNS(xmlns, \"math\");\n\t\t\tel.innerHTML = value;\n\t\t\tnodes = Array.from(el.childNodes);\n\t\t} else {\n\t\t\tnodes = value == null ? [] : Array.isArray(value) ? [...value] : [value];\n\t\t}\n\n\t\tif (hydrationNodes != null) {\n\t\t\tfor (let i = 0; i < nodes.length; i++) {\n\t\t\t\tconst node = nodes[i];\n\t\t\t\t// check if node is equal to the next node in the hydration array\n\t\t\t\tconst hydrationNode = hydrationNodes.shift();\n\t\t\t\tif (\n\t\t\t\t\thydrationNode &&\n\t\t\t\t\ttypeof hydrationNode === \"object\" &&\n\t\t\t\t\ttypeof hydrationNode.nodeType === \"number\" &&\n\t\t\t\t\tnode.isEqualNode(hydrationNode as Node)\n\t\t\t\t) {\n\t\t\t\t\tnodes[i] = hydrationNode as Node;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Expected <Raw value=\"${String(value)}\"> while hydrating but found:`,\n\t\t\t\t\t\thydrationNode,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes.length === 0\n\t\t\t? undefined\n\t\t\t: nodes.length === 1\n\t\t\t\t? nodes[0]\n\t\t\t\t: nodes;\n\t},\n};\n\nexport class DOMRenderer extends Renderer<Node, string, Element> {\n\tconstructor() {\n\t\tsuper(adapter);\n\t}\n\n\trender(\n\t\tchildren: Children,\n\t\troot: Element,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.render(children, root, ctx);\n\t}\n\n\thydrate(\n\t\tchildren: Children,\n\t\troot: Element,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.hydrate(children, root, ctx);\n\t}\n}\n\nfunction validateRoot(root: unknown): asserts root is Element {\n\tif (\n\t\troot == null ||\n\t\t(typeof root === \"object\" && typeof (root as any).nodeType !== \"number\")\n\t) {\n\t\tthrow new TypeError(`Render root is not a node. Received: ${String(root)}`);\n\t} else if ((root as Node).nodeType !== Node.ELEMENT_NODE) {\n\t\tthrow new TypeError(\n\t\t\t`Render root must be an element node. Received: ${String(root)}`,\n\t\t);\n\t}\n}\n\nexport const renderer = new DOMRenderer();\n\ndeclare global {\n\tmodule Crank {\n\t\tinterface EventMap extends GlobalEventHandlersEventMap {}\n\t}\n}\n"],"names":["Portal","camelToKebabCase","formatStyleValue","Renderer"],"mappings":";;;;;AAUA,MAAM,aAAa,GAAG,4BAA4B;AAClD,MAAM,gBAAgB,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IAAI,SAAS,CAClB,CAAkD,+CAAA,EAAA,MAAM,CAAC,IAAI,CAAC,CAAE,CAAA,CAChE;;AAEH;AAEa,MAAA,QAAQ,GAAG,IAAI,WAAW;;;;;;"}
|
|
1
|
+
{"version":3,"file":"dom.cjs","sources":["../src/dom.ts"],"sourcesContent":["import {\n\tChildren,\n\tContext,\n\tElementValue,\n\tPortal,\n\tRenderer,\n\tRenderAdapter,\n} from \"./crank.js\";\nimport {camelToKebabCase, formatStyleValue} from \"./_css.js\";\n\nconst SVG_NAMESPACE = \"http://www.w3.org/2000/svg\";\nconst MATHML_NAMESPACE = \"http://www.w3.org/1998/Math/MathML\";\n\nfunction getRootDocument(root: Node | undefined): Document {\n\tif (root && root.ownerDocument) {\n\t\treturn root.ownerDocument;\n\t}\n\n\tif (root && root.nodeType === Node.DOCUMENT_NODE) {\n\t\treturn root as unknown as Document;\n\t}\n\n\treturn document;\n}\n\nfunction isWritableProperty(element: Element, name: string): boolean {\n\t// walk up the object's prototype chain to find the owner\n\tlet propOwner = element;\n\tdo {\n\t\tif (Object.prototype.hasOwnProperty.call(propOwner, name)) {\n\t\t\tbreak;\n\t\t}\n\t} while ((propOwner = Object.getPrototypeOf(propOwner)));\n\n\tif (propOwner === null) {\n\t\treturn false;\n\t}\n\n\t// get the descriptor for the named property and check whether it implies\n\t// that the property is writable\n\tconst descriptor = Object.getOwnPropertyDescriptor(propOwner, name);\n\tif (\n\t\tdescriptor != null &&\n\t\t(descriptor.writable === true || descriptor.set !== undefined)\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction emitHydrationWarning(\n\tpropName: string,\n\tquietProps: Set<string> | undefined,\n\texpectedValue: any,\n\tactualValue: any,\n\telement: Element,\n\tdisplayName?: string,\n) {\n\tconst checkName = propName;\n\tconst showName = displayName || propName;\n\tif (!quietProps || !quietProps.has(checkName)) {\n\t\tif (expectedValue === null || expectedValue === false) {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be missing but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else if (expectedValue === true || expectedValue === \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be ${expectedValue === true ? \"present\" : '\"\"'} but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t} else {\n\t\t\t// Check if this is a URL mismatch that's actually just resolution\n\t\t\tconst win = element.ownerDocument.defaultView;\n\t\t\tif (win && win.location) {\n\t\t\t\tconst origin = win.location.origin;\n\t\t\t\tif (\n\t\t\t\t\tnew URL(expectedValue, origin).href ===\n\t\t\t\t\tnew URL(actualValue, origin).href\n\t\t\t\t) {\n\t\t\t\t\t// attrs which are URLs will often be resolved to their full\n\t\t\t\t\t// href in the DOM, so we squash these errors\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconsole.warn(\n\t\t\t\t`Expected \"${showName}\" to be \"${String(expectedValue)}\" but found ${String(actualValue)} while hydrating:`,\n\t\t\t\telement,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport const adapter: Partial<RenderAdapter<Node, string, Node>> = {\n\tscope({\n\t\tscope: xmlns,\n\t\ttag,\n\t\tprops,\n\t}: {\n\t\tscope: string | undefined;\n\t\ttag: string | symbol;\n\t\tprops: Record<string, any>;\n\t\troot: Node | undefined;\n\t}): string | undefined {\n\t\tswitch (tag) {\n\t\t\tcase Portal:\n\t\t\t\t// TODO: read the namespace from the portal root element\n\t\t\t\txmlns = undefined;\n\t\t\t\tbreak;\n\t\t\tcase \"svg\":\n\t\t\t\txmlns = SVG_NAMESPACE;\n\t\t\t\tbreak;\n\t\t\tcase \"math\":\n\t\t\t\txmlns = MATHML_NAMESPACE;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn props.xmlns || xmlns;\n\t},\n\n\tcreate({\n\t\ttag,\n\t\ttagName,\n\t\tscope: xmlns,\n\t\troot,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tscope: string | undefined;\n\t\troot: Node | undefined;\n\t}): Node {\n\t\tif (typeof tag !== \"string\") {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t} else if (tag.toLowerCase() === \"svg\") {\n\t\t\txmlns = SVG_NAMESPACE;\n\t\t} else if (tag.toLowerCase() === \"math\") {\n\t\t\txmlns = MATHML_NAMESPACE;\n\t\t}\n\n\t\tconst doc = getRootDocument(root);\n\t\treturn xmlns ? doc.createElementNS(xmlns, tag) : doc.createElement(tag);\n\t},\n\n\tadopt({\n\t\ttag,\n\t\ttagName,\n\t\tnode,\n\t\troot,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tnode: Node | undefined;\n\t\troot: Node | undefined;\n\t}): Array<Node> | undefined {\n\t\tif (typeof tag !== \"string\" && tag !== Portal) {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t}\n\n\t\tconst doc = getRootDocument(root);\n\t\tif (\n\t\t\tnode === doc.body ||\n\t\t\tnode === doc.head ||\n\t\t\tnode === doc.documentElement ||\n\t\t\tnode === doc\n\t\t) {\n\t\t\tconsole.warn(\n\t\t\t\t`Hydrating ${node.nodeName.toLowerCase()} is discouraged as it is destructive and may remove unknown nodes.`,\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\tnode == null ||\n\t\t\t(typeof tag === \"string\" &&\n\t\t\t\t(node.nodeType !== Node.ELEMENT_NODE ||\n\t\t\t\t\ttag.toLowerCase() !== (node as Element).tagName.toLowerCase()))\n\t\t) {\n\t\t\tconsole.warn(`Expected <${tagName}> while hydrating but found: `, node);\n\t\t\treturn;\n\t\t}\n\n\t\treturn Array.from(node.childNodes);\n\t},\n\n\tpatch({\n\t\ttagName,\n\t\tnode,\n\t\tprops,\n\t\toldProps,\n\t\tscope: xmlns,\n\t\tcopyProps,\n\t\tquietProps,\n\t\tisHydrating,\n\t}: {\n\t\tnode: Node;\n\t\ttagName: string;\n\t\tprops: Record<string, any>;\n\t\toldProps: Record<string, any> | undefined;\n\t\tscope: string | undefined;\n\t\troot: Node | undefined;\n\t\tcopyProps: Set<string> | undefined;\n\t\tquietProps: Set<string> | undefined;\n\t\tisHydrating: boolean;\n\t}): void {\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) {\n\t\t\tthrow new TypeError(`Cannot patch node: ${String(node)}`);\n\t\t} else if (props.class && props.className) {\n\t\t\tconsole.error(\n\t\t\t\t`Both \"class\" and \"className\" set in props for <${tagName}>. Use one or the other.`,\n\t\t\t);\n\t\t}\n\n\t\tconst element = node as Element;\n\t\tconst isSVG = xmlns === SVG_NAMESPACE;\n\t\tconst isMathML = xmlns === MATHML_NAMESPACE;\n\t\tfor (let name in {...oldProps, ...props}) {\n\t\t\tlet value = props[name];\n\t\t\tconst oldValue = oldProps ? oldProps[name] : undefined;\n\t\t\t{\n\t\t\t\tif (copyProps != null && copyProps.has(name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// handle prop:name or attr:name properties\n\t\t\t\tconst colonIndex = name.indexOf(\":\");\n\t\t\t\tif (colonIndex !== -1) {\n\t\t\t\t\tconst [ns, name1] = [\n\t\t\t\t\t\tname.slice(0, colonIndex),\n\t\t\t\t\t\tname.slice(colonIndex + 1),\n\t\t\t\t\t];\n\t\t\t\t\tswitch (ns) {\n\t\t\t\t\t\tcase \"prop\":\n\t\t\t\t\t\t\t(node as any)[name1] = value;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tcase \"attr\":\n\t\t\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.removeAttribute(name1);\n\t\t\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\t\t\tif (isHydrating && !element.hasAttribute(name1)) {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(name, quietProps, value, null, element);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telement.setAttribute(name1, \"\");\n\t\t\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (isHydrating && element.getAttribute(name1) !== value) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.getAttribute(name1),\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\telement.setAttribute(name1, String(value));\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (name) {\n\t\t\t\t// TODO: fix hydration warnings for the style prop\n\t\t\t\tcase \"style\": {\n\t\t\t\t\tconst style = (element as HTMLElement | SVGElement).style;\n\t\t\t\t\tif (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.removeAttribute(\"style\");\n\t\t\t\t\t} else if (value === true) {\n\t\t\t\t\t\tif (isHydrating && style.cssText !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\tstyle.cssText,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"style\", \"\");\n\t\t\t\t\t} else if (typeof value === \"string\") {\n\t\t\t\t\t\tif (style.cssText !== value) {\n\t\t\t\t\t\t\t// TODO: Fix hydration warnings for styles\n\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t//\t\tvalue,\n\t\t\t\t\t\t\t//\t\tstyle.cssText,\n\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t//}\n\n\t\t\t\t\t\t\tstyle.cssText = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear the style\n\t\t\t\t\t\t\t// TODO: only clear the styles enumerated in the old value\n\t\t\t\t\t\t\tstyle.cssText = \"\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const styleName in {...oldValue, ...value}) {\n\t\t\t\t\t\t\tconst cssName = camelToKebabCase(styleName);\n\t\t\t\t\t\t\tconst styleValue = value && (value as any)[styleName];\n\t\t\t\t\t\t\tif (styleValue == null) {\n\t\t\t\t\t\t\t\tif (isHydrating && style.getPropertyValue(cssName) !== \"\") {\n\t\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstyle.removeProperty(cssName);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst formattedValue = formatStyleValue(cssName, styleValue);\n\t\t\t\t\t\t\t\tif (style.getPropertyValue(cssName) !== formattedValue) {\n\t\t\t\t\t\t\t\t\t// TODO: hydration warnings for style props\n\t\t\t\t\t\t\t\t\t//if (isHydrating) {\n\t\t\t\t\t\t\t\t\t//\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\t//\t\tname,\n\t\t\t\t\t\t\t\t\t//\t\tquietProps,\n\t\t\t\t\t\t\t\t\t//\t\tformattedValue,\n\t\t\t\t\t\t\t\t\t//\t\tstyle.getPropertyValue(cssName),\n\t\t\t\t\t\t\t\t\t//\t\telement,\n\t\t\t\t\t\t\t\t\t//\t\t`style.${styleName}`,\n\t\t\t\t\t\t\t\t\t//\t);\n\t\t\t\t\t\t\t\t\t//}\n\t\t\t\t\t\t\t\t\tstyle.setProperty(cssName, formattedValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"class\":\n\t\t\t\tcase \"className\":\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tif (isHydrating && element.getAttribute(\"class\") !== \"\") {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t} else if (value == null) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(\"class\")) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(\"class\");\n\t\t\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\t\t\t// class={{\"included-class\": true, \"excluded-class\": false}} syntax\n\t\t\t\t\t\tif (typeof oldValue === \"string\") {\n\t\t\t\t\t\t\t// if the old value was a string, we need to clear all classes\n\t\t\t\t\t\t\telement.setAttribute(\"class\", \"\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet shouldIssueWarning = false;\n\t\t\t\t\t\tconst hydratingClasses = isHydrating\n\t\t\t\t\t\t\t? new Set(Array.from(element.classList))\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tconst hydratingClassName = isHydrating\n\t\t\t\t\t\t\t? element.getAttribute(\"class\")\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\tconst allClassNames = {...oldValue, ...value};\n\t\t\t\t\t\t// Two passes: removes first, then adds. This ensures that\n\t\t\t\t\t\t// overlapping classes in different keys are handled correctly.\n\t\t\t\t\t\t// e.g. {\"a b\": false, \"b c\": true} should result in \"b c\"\n\t\t\t\t\t\tfor (const classNames in allClassNames) {\n\t\t\t\t\t\t\tif (!(value && value[classNames])) {\n\t\t\t\t\t\t\t\tconst classes = classNames.split(/\\s+/).filter(Boolean);\n\t\t\t\t\t\t\t\telement.classList.remove(...classes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const classNames in allClassNames) {\n\t\t\t\t\t\t\tif (value && value[classNames]) {\n\t\t\t\t\t\t\t\tconst classes = classNames.split(/\\s+/).filter(Boolean);\n\t\t\t\t\t\t\t\telement.classList.add(...classes);\n\t\t\t\t\t\t\t\tfor (const className of classes) {\n\t\t\t\t\t\t\t\t\tif (hydratingClasses && hydratingClasses.has(className)) {\n\t\t\t\t\t\t\t\t\t\thydratingClasses.delete(className);\n\t\t\t\t\t\t\t\t\t} else if (isHydrating) {\n\t\t\t\t\t\t\t\t\t\tshouldIssueWarning = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldIssueWarning ||\n\t\t\t\t\t\t\t(hydratingClasses && hydratingClasses.size > 0)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tObject.keys(value)\n\t\t\t\t\t\t\t\t\t.filter((k) => value[k])\n\t\t\t\t\t\t\t\t\t.join(\" \"),\n\t\t\t\t\t\t\t\thydratingClassName || \"\",\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!isSVG && !isMathML) {\n\t\t\t\t\t\tif (element.className !== value) {\n\t\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\telement.className,\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telement.className = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (element.getAttribute(\"class\") !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(\"class\"),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.setAttribute(\"class\", value as string);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"innerHTML\":\n\t\t\t\t\tif (value !== oldValue) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.innerHTML,\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telement.innerHTML = value as any;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tname[0] === \"o\" &&\n\t\t\t\t\t\tname[1] === \"n\" &&\n\t\t\t\t\t\tname[2] === name[2].toUpperCase() &&\n\t\t\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Support React-style event names (onClick, onChange, etc.)\n\t\t\t\t\t\tname = name.toLowerCase();\n\t\t\t\t\t}\n\n\t\t\t\t\t// try to set the property directly\n\t\t\t\t\tif (\n\t\t\t\t\t\tname in element &&\n\t\t\t\t\t\t// boolean properties will coerce strings, but sometimes they map to\n\t\t\t\t\t\t// enumerated attributes, where truthy strings (\"false\", \"no\") map to\n\t\t\t\t\t\t// falsy properties, so we force using setAttribute.\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\t\ttypeof (element as any)[name] === \"boolean\"\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tisWritableProperty(element, name)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// For URL properties like src and href, the DOM property returns the\n\t\t\t\t\t\t// resolved absolute URL. We need to resolve the prop value the same way\n\t\t\t\t\t\t// to compare correctly.\n\t\t\t\t\t\tlet domValue = (element as any)[name];\n\t\t\t\t\t\tlet propValue = value;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(name === \"src\" || name === \"href\") &&\n\t\t\t\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\t\t\t\ttypeof domValue === \"string\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tpropValue = new URL(value, element.baseURI).href;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t// Invalid URL, use original value for comparison\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (propValue !== domValue || oldValue === undefined) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisHydrating &&\n\t\t\t\t\t\t\t\ttypeof (element as any)[name] === \"string\" &&\n\t\t\t\t\t\t\t\t(element as any)[name] !== value\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t(element as any)[name],\n\t\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// if the property is writable, assign it directly\n\t\t\t\t\t\t\t(element as any)[name] = value;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (value === true) {\n\t\t\t\t\t\tvalue = \"\";\n\t\t\t\t\t} else if (value == null || value === false) {\n\t\t\t\t\t\tif (isHydrating && element.hasAttribute(name)) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.removeAttribute(name);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (typeof value !== \"string\") {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (element.getAttribute(name) !== value) {\n\t\t\t\t\t\tif (isHydrating) {\n\t\t\t\t\t\t\temitHydrationWarning(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tquietProps,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\telement.getAttribute(name),\n\t\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telement.setAttribute(name, value as any);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tarrange({\n\t\ttag,\n\t\tnode,\n\t\tprops,\n\t\tchildren,\n\t}: {\n\t\ttag: string | symbol;\n\t\tnode: Node;\n\t\tprops: Record<string, any>;\n\t\tchildren: Array<Node>;\n\t\troot: Node | undefined;\n\t}): void {\n\t\tif (tag === Portal && (node == null || typeof node.nodeType !== \"number\")) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`<Portal> root is not a node. Received: ${String(node)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"innerHTML\" in props)) {\n\t\t\tlet oldChild = node.firstChild;\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tconst newChild = children[i];\n\t\t\t\tif (oldChild === newChild) {\n\t\t\t\t\t// the child is already in the right place, so we can skip it\n\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t} else {\n\t\t\t\t\tnode.insertBefore(newChild, oldChild);\n\t\t\t\t\tif (\n\t\t\t\t\t\ttag !== Portal &&\n\t\t\t\t\t\toldChild &&\n\t\t\t\t\t\ti + 1 < children.length &&\n\t\t\t\t\t\toldChild !== children[i + 1]\n\t\t\t\t\t) {\n\t\t\t\t\t\toldChild = oldChild.nextSibling;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tremove({\n\t\tnode,\n\t\tparentNode,\n\t\tisNested,\n\t}: {\n\t\tnode: Node;\n\t\tparentNode: Node;\n\t\tisNested: boolean;\n\t\troot: Node | undefined;\n\t}): void {\n\t\tif (!isNested && node.parentNode === parentNode) {\n\t\t\tparentNode.removeChild(node);\n\t\t}\n\t},\n\n\ttext({\n\t\tvalue,\n\t\toldNode,\n\t\thydrationNodes,\n\t\troot,\n\t}: {\n\t\tvalue: string;\n\t\thydrationNodes: Array<Node> | undefined;\n\t\toldNode: Node | undefined;\n\t\troot: Node | undefined;\n\t}): Node {\n\t\tconst doc = getRootDocument(root);\n\t\tif (hydrationNodes != null) {\n\t\t\tlet node = hydrationNodes.shift();\n\t\t\tif (!node || node.nodeType !== Node.TEXT_NODE) {\n\t\t\t\tconsole.warn(`Expected \"${value}\" while hydrating but found:`, node);\n\t\t\t} else {\n\t\t\t\t// value is a text node, check if it matches the expected text\n\t\t\t\tconst textData = (node as Text).data;\n\t\t\t\tif (textData.length > value.length) {\n\t\t\t\t\tif (textData.startsWith(value)) {\n\t\t\t\t\t\t// the text node is longer than the expected text, so we\n\t\t\t\t\t\t// reuse the existing text node, but truncate it and unshift the rest\n\t\t\t\t\t\t(node as Text).data = value;\n\t\t\t\t\t\thydrationNodes.unshift(\n\t\t\t\t\t\t\tdoc.createTextNode(textData.slice(value.length)),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn node;\n\t\t\t\t\t}\n\t\t\t\t} else if (textData === value) {\n\t\t\t\t\treturn node;\n\t\t\t\t}\n\n\t\t\t\t// We log textData and not node because node will be mutated\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Expected \"${value}\" while hydrating but found:`,\n\t\t\t\t\ttextData,\n\t\t\t\t);\n\t\t\t\toldNode = node;\n\t\t\t}\n\t\t}\n\n\t\tif (oldNode != null) {\n\t\t\tif ((oldNode as Text).data !== value) {\n\t\t\t\t(oldNode as Text).data = value;\n\t\t\t}\n\n\t\t\treturn oldNode;\n\t\t}\n\n\t\treturn doc.createTextNode(value);\n\t},\n\n\traw({\n\t\tvalue,\n\t\tscope: xmlns,\n\t\thydrationNodes,\n\t\troot,\n\t}: {\n\t\tvalue: string | Node;\n\t\tscope: string | undefined;\n\t\thydrationNodes: Array<Node> | undefined;\n\t\troot: Node | undefined;\n\t}): ElementValue<Node> {\n\t\tlet nodes: Array<Node>;\n\t\tif (typeof value === \"string\") {\n\t\t\tconst doc = getRootDocument(root);\n\t\t\tconst el =\n\t\t\t\txmlns == null\n\t\t\t\t\t? doc.createElement(\"div\")\n\t\t\t\t\t: xmlns === SVG_NAMESPACE\n\t\t\t\t\t\t? doc.createElementNS(xmlns, \"svg\")\n\t\t\t\t\t\t: doc.createElementNS(xmlns, \"math\");\n\t\t\tel.innerHTML = value;\n\t\t\tnodes = Array.from(el.childNodes);\n\t\t} else {\n\t\t\tnodes = value == null ? [] : Array.isArray(value) ? [...value] : [value];\n\t\t}\n\n\t\tif (hydrationNodes != null) {\n\t\t\tfor (let i = 0; i < nodes.length; i++) {\n\t\t\t\tconst node = nodes[i];\n\t\t\t\t// check if node is equal to the next node in the hydration array\n\t\t\t\tconst hydrationNode = hydrationNodes.shift();\n\t\t\t\tif (\n\t\t\t\t\thydrationNode &&\n\t\t\t\t\ttypeof hydrationNode === \"object\" &&\n\t\t\t\t\ttypeof hydrationNode.nodeType === \"number\" &&\n\t\t\t\t\tnode.isEqualNode(hydrationNode as Node)\n\t\t\t\t) {\n\t\t\t\t\tnodes[i] = hydrationNode as Node;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Expected <Raw value=\"${String(value)}\"> while hydrating but found:`,\n\t\t\t\t\t\thydrationNode,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes.length === 0\n\t\t\t? undefined\n\t\t\t: nodes.length === 1\n\t\t\t\t? nodes[0]\n\t\t\t\t: nodes;\n\t},\n};\n\nexport class DOMRenderer extends Renderer<Node, string, Element> {\n\tconstructor() {\n\t\tsuper(adapter);\n\t}\n\n\trender(\n\t\tchildren: Children,\n\t\troot: Element,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.render(children, root, ctx);\n\t}\n\n\thydrate(\n\t\tchildren: Children,\n\t\troot: Element,\n\t\tctx?: Context,\n\t): Promise<ElementValue<Node>> | ElementValue<Node> {\n\t\tvalidateRoot(root);\n\t\treturn super.hydrate(children, root, ctx);\n\t}\n}\n\nfunction validateRoot(root: unknown): asserts root is Element {\n\tif (\n\t\troot == null ||\n\t\t(typeof root === \"object\" && typeof (root as any).nodeType !== \"number\")\n\t) {\n\t\tthrow new TypeError(`Render root is not a node. Received: ${String(root)}`);\n\t} else if ((root as Node).nodeType !== Node.ELEMENT_NODE) {\n\t\tthrow new TypeError(\n\t\t\t`Render root must be an element node. Received: ${String(root)}`,\n\t\t);\n\t}\n}\n\nexport const renderer = new DOMRenderer();\n\ndeclare global {\n\tmodule Crank {\n\t\tinterface EventMap extends GlobalEventHandlersEventMap {}\n\t}\n}\n"],"names":["Portal","camelToKebabCase","formatStyleValue","Renderer"],"mappings":";;;;;AAUA,MAAM,aAAa,GAAG,4BAA4B;AAClD,MAAM,gBAAgB,GAAG,oCAAoC;AAE7D,SAAS,eAAe,CAAC,IAAsB,EAAA;AAC9C,IAAA,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,EAAE;QAC/B,OAAO,IAAI,CAAC,aAAa;IAC1B;IAEA,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,aAAa,EAAE;AACjD,QAAA,OAAO,IAA2B;IACnC;AAEA,IAAA,OAAO,QAAQ;AAChB;AAEA,SAAS,kBAAkB,CAAC,OAAgB,EAAE,IA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OAAO,IAAI,KAAK,QAAQ,IAAI,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ,CAAC,EACvE;QACD,MAAM,IAAI,SAAS,CAAC,CAAA,qCAAA,EAAwC,MAAM,CAAC,IAAI,CAAC,CAAA,CAAE,CAAC;IAC5E;SAAO,IAAK,IAAa,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE;QACzD,MAAM,IAAI,SAAS,CAClB,CAAA,+CAAA,EAAkD,MAAM,CAAC,IAAI,CAAC,CAAA,CAAE,CAChE;IACF;AACD;AAEO,MAAM,QAAQ,GAAG,IAAI,WAAW;;;;;;"}
|
package/dom.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Children, Context, ElementValue, Renderer, RenderAdapter } from "./crank.js";
|
|
2
|
-
export declare const adapter: Partial<RenderAdapter<Node, string,
|
|
2
|
+
export declare const adapter: Partial<RenderAdapter<Node, string, Node>>;
|
|
3
3
|
export declare class DOMRenderer extends Renderer<Node, string, Element> {
|
|
4
4
|
constructor();
|
|
5
5
|
render(children: Children, root: Element, ctx?: Context): Promise<ElementValue<Node>> | ElementValue<Node>;
|
package/dom.js
CHANGED
|
@@ -4,6 +4,15 @@ import { camelToKebabCase, formatStyleValue } from './_css.js';
|
|
|
4
4
|
|
|
5
5
|
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
6
6
|
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
7
|
+
function getRootDocument(root) {
|
|
8
|
+
if (root && root.ownerDocument) {
|
|
9
|
+
return root.ownerDocument;
|
|
10
|
+
}
|
|
11
|
+
if (root && root.nodeType === Node.DOCUMENT_NODE) {
|
|
12
|
+
return root;
|
|
13
|
+
}
|
|
14
|
+
return document;
|
|
15
|
+
}
|
|
7
16
|
function isWritableProperty(element, name) {
|
|
8
17
|
// walk up the object's prototype chain to find the owner
|
|
9
18
|
let propOwner = element;
|
|
@@ -34,11 +43,18 @@ function emitHydrationWarning(propName, quietProps, expectedValue, actualValue,
|
|
|
34
43
|
else if (expectedValue === true || expectedValue === "") {
|
|
35
44
|
console.warn(`Expected "${showName}" to be ${expectedValue === true ? "present" : '""'} but found ${String(actualValue)} while hydrating:`, element);
|
|
36
45
|
}
|
|
37
|
-
else if (typeof window !== "undefined" &&
|
|
38
|
-
window.location &&
|
|
39
|
-
new URL(expectedValue, window.location.origin).href ===
|
|
40
|
-
new URL(actualValue, window.location.origin).href) ;
|
|
41
46
|
else {
|
|
47
|
+
// Check if this is a URL mismatch that's actually just resolution
|
|
48
|
+
const win = element.ownerDocument.defaultView;
|
|
49
|
+
if (win && win.location) {
|
|
50
|
+
const origin = win.location.origin;
|
|
51
|
+
if (new URL(expectedValue, origin).href ===
|
|
52
|
+
new URL(actualValue, origin).href) {
|
|
53
|
+
// attrs which are URLs will often be resolved to their full
|
|
54
|
+
// href in the DOM, so we squash these errors
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
42
58
|
console.warn(`Expected "${showName}" to be "${String(expectedValue)}" but found ${String(actualValue)} while hydrating:`, element);
|
|
43
59
|
}
|
|
44
60
|
}
|
|
@@ -59,7 +75,7 @@ const adapter = {
|
|
|
59
75
|
}
|
|
60
76
|
return props.xmlns || xmlns;
|
|
61
77
|
},
|
|
62
|
-
create({ tag, tagName, scope: xmlns, }) {
|
|
78
|
+
create({ tag, tagName, scope: xmlns, root, }) {
|
|
63
79
|
if (typeof tag !== "string") {
|
|
64
80
|
throw new Error(`Unknown tag: ${tagName}`);
|
|
65
81
|
}
|
|
@@ -69,18 +85,18 @@ const adapter = {
|
|
|
69
85
|
else if (tag.toLowerCase() === "math") {
|
|
70
86
|
xmlns = MATHML_NAMESPACE;
|
|
71
87
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
: document.createElement(tag);
|
|
88
|
+
const doc = getRootDocument(root);
|
|
89
|
+
return xmlns ? doc.createElementNS(xmlns, tag) : doc.createElement(tag);
|
|
75
90
|
},
|
|
76
|
-
adopt({ tag, tagName, node, }) {
|
|
91
|
+
adopt({ tag, tagName, node, root, }) {
|
|
77
92
|
if (typeof tag !== "string" && tag !== Portal) {
|
|
78
93
|
throw new Error(`Unknown tag: ${tagName}`);
|
|
79
94
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
node ===
|
|
83
|
-
node ===
|
|
95
|
+
const doc = getRootDocument(root);
|
|
96
|
+
if (node === doc.body ||
|
|
97
|
+
node === doc.head ||
|
|
98
|
+
node === doc.documentElement ||
|
|
99
|
+
node === doc) {
|
|
84
100
|
console.warn(`Hydrating ${node.nodeName.toLowerCase()} is discouraged as it is destructive and may remove unknown nodes.`);
|
|
85
101
|
}
|
|
86
102
|
if (node == null ||
|
|
@@ -238,19 +254,28 @@ const adapter = {
|
|
|
238
254
|
const hydratingClassName = isHydrating
|
|
239
255
|
? element.getAttribute("class")
|
|
240
256
|
: undefined;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
shouldIssueWarning = true;
|
|
250
|
-
}
|
|
257
|
+
const allClassNames = { ...oldValue, ...value };
|
|
258
|
+
// Two passes: removes first, then adds. This ensures that
|
|
259
|
+
// overlapping classes in different keys are handled correctly.
|
|
260
|
+
// e.g. {"a b": false, "b c": true} should result in "b c"
|
|
261
|
+
for (const classNames in allClassNames) {
|
|
262
|
+
if (!(value && value[classNames])) {
|
|
263
|
+
const classes = classNames.split(/\s+/).filter(Boolean);
|
|
264
|
+
element.classList.remove(...classes);
|
|
251
265
|
}
|
|
252
|
-
|
|
253
|
-
|
|
266
|
+
}
|
|
267
|
+
for (const classNames in allClassNames) {
|
|
268
|
+
if (value && value[classNames]) {
|
|
269
|
+
const classes = classNames.split(/\s+/).filter(Boolean);
|
|
270
|
+
element.classList.add(...classes);
|
|
271
|
+
for (const className of classes) {
|
|
272
|
+
if (hydratingClasses && hydratingClasses.has(className)) {
|
|
273
|
+
hydratingClasses.delete(className);
|
|
274
|
+
}
|
|
275
|
+
else if (isHydrating) {
|
|
276
|
+
shouldIssueWarning = true;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
254
279
|
}
|
|
255
280
|
}
|
|
256
281
|
if (shouldIssueWarning ||
|
|
@@ -299,7 +324,22 @@ const adapter = {
|
|
|
299
324
|
!(typeof value === "string" &&
|
|
300
325
|
typeof element[name] === "boolean") &&
|
|
301
326
|
isWritableProperty(element, name)) {
|
|
302
|
-
|
|
327
|
+
// For URL properties like src and href, the DOM property returns the
|
|
328
|
+
// resolved absolute URL. We need to resolve the prop value the same way
|
|
329
|
+
// to compare correctly.
|
|
330
|
+
let domValue = element[name];
|
|
331
|
+
let propValue = value;
|
|
332
|
+
if ((name === "src" || name === "href") &&
|
|
333
|
+
typeof value === "string" &&
|
|
334
|
+
typeof domValue === "string") {
|
|
335
|
+
try {
|
|
336
|
+
propValue = new URL(value, element.baseURI).href;
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
// Invalid URL, use original value for comparison
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (propValue !== domValue || oldValue === undefined) {
|
|
303
343
|
if (isHydrating &&
|
|
304
344
|
typeof element[name] === "string" &&
|
|
305
345
|
element[name] !== value) {
|
|
@@ -362,7 +402,8 @@ const adapter = {
|
|
|
362
402
|
parentNode.removeChild(node);
|
|
363
403
|
}
|
|
364
404
|
},
|
|
365
|
-
text({ value, oldNode, hydrationNodes, }) {
|
|
405
|
+
text({ value, oldNode, hydrationNodes, root, }) {
|
|
406
|
+
const doc = getRootDocument(root);
|
|
366
407
|
if (hydrationNodes != null) {
|
|
367
408
|
let node = hydrationNodes.shift();
|
|
368
409
|
if (!node || node.nodeType !== Node.TEXT_NODE) {
|
|
@@ -376,7 +417,7 @@ const adapter = {
|
|
|
376
417
|
// the text node is longer than the expected text, so we
|
|
377
418
|
// reuse the existing text node, but truncate it and unshift the rest
|
|
378
419
|
node.data = value;
|
|
379
|
-
hydrationNodes.unshift(
|
|
420
|
+
hydrationNodes.unshift(doc.createTextNode(textData.slice(value.length)));
|
|
380
421
|
return node;
|
|
381
422
|
}
|
|
382
423
|
}
|
|
@@ -394,16 +435,17 @@ const adapter = {
|
|
|
394
435
|
}
|
|
395
436
|
return oldNode;
|
|
396
437
|
}
|
|
397
|
-
return
|
|
438
|
+
return doc.createTextNode(value);
|
|
398
439
|
},
|
|
399
|
-
raw({ value, scope: xmlns, hydrationNodes, }) {
|
|
440
|
+
raw({ value, scope: xmlns, hydrationNodes, root, }) {
|
|
400
441
|
let nodes;
|
|
401
442
|
if (typeof value === "string") {
|
|
443
|
+
const doc = getRootDocument(root);
|
|
402
444
|
const el = xmlns == null
|
|
403
|
-
?
|
|
445
|
+
? doc.createElement("div")
|
|
404
446
|
: xmlns === SVG_NAMESPACE
|
|
405
|
-
?
|
|
406
|
-
:
|
|
447
|
+
? doc.createElementNS(xmlns, "svg")
|
|
448
|
+
: doc.createElementNS(xmlns, "math");
|
|
407
449
|
el.innerHTML = value;
|
|
408
450
|
nodes = Array.from(el.childNodes);
|
|
409
451
|
}
|