tutuca 0.9.66 → 0.9.67

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.
@@ -1172,40 +1172,49 @@ class RequestHandler {
1172
1172
  }
1173
1173
 
1174
1174
  // src/vdom.js
1175
- var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
1176
1175
  var HTML_NS = "http://www.w3.org/1999/xhtml";
1177
1176
  var isNamespaced = (node) => {
1178
1177
  const ns = node.namespaceURI;
1179
1178
  return ns !== null && ns !== HTML_NS;
1180
1179
  };
1181
- function applyProperties(node, props, previous) {
1180
+ var NEVER_ASSIGN = new Set([
1181
+ "width",
1182
+ "height",
1183
+ "href",
1184
+ "list",
1185
+ "form",
1186
+ "tabIndex",
1187
+ "download",
1188
+ "rowSpan",
1189
+ "colSpan",
1190
+ "role",
1191
+ "popover"
1192
+ ]);
1193
+ function applyProperties(node, props, _previous) {
1182
1194
  const namespaced = isNamespaced(node);
1183
- for (const propName in props) {
1184
- const propValue = props[propName];
1185
- if (propValue === undefined)
1186
- removeProperty(node, propName, previous);
1187
- else if (propName === "dangerouslySetInnerHTML")
1188
- node.innerHTML = propValue.__html ?? "";
1189
- else if (propName === "className")
1190
- node.setAttribute("class", propValue);
1191
- else if (namespaced || isHtmlAttribute(propName))
1192
- node.setAttribute(propName, propValue);
1195
+ for (const name in props)
1196
+ setProp(node, name, props[name], namespaced);
1197
+ }
1198
+ function setProp(node, name, value, namespaced) {
1199
+ if (name === "dangerouslySetInnerHTML") {
1200
+ if (value === undefined)
1201
+ node.replaceChildren();
1193
1202
  else
1194
- node[propName] = propValue;
1195
- }
1196
- }
1197
- function removeProperty(node, propName, previous) {
1198
- const previousValue = previous[propName];
1199
- if (propName === "dangerouslySetInnerHTML")
1200
- node.replaceChildren();
1201
- else if (propName === "className")
1202
- node.removeAttribute("class");
1203
- else if (propName === "htmlFor")
1204
- node.removeAttribute("for");
1205
- else if (isNamespaced(node) || typeof previousValue === "string" || isHtmlAttribute(propName))
1206
- node.removeAttribute(propName);
1203
+ node.innerHTML = value.__html ?? "";
1204
+ return;
1205
+ }
1206
+ if (typeof value === "function")
1207
+ return;
1208
+ if (!namespaced && !NEVER_ASSIGN.has(name) && name in node) {
1209
+ try {
1210
+ node[name] = value == null ? "" : value;
1211
+ return;
1212
+ } catch {}
1213
+ }
1214
+ if (value == null || value === false && name[4] !== "-")
1215
+ node.removeAttribute(name);
1207
1216
  else
1208
- node[propName] = null;
1217
+ node.setAttribute(name, value);
1209
1218
  }
1210
1219
 
1211
1220
  class VBase {
@@ -1477,22 +1486,12 @@ function h(tagName, properties, children, namespace) {
1477
1486
  if (properties) {
1478
1487
  for (const propName in properties) {
1479
1488
  const propVal = properties[propName];
1480
- switch (propName) {
1481
- case "key":
1482
- key = propVal;
1483
- break;
1484
- case "namespace":
1485
- namespace = namespace ?? propVal;
1486
- break;
1487
- case "class":
1488
- props.className = propVal;
1489
- break;
1490
- case "for":
1491
- props.htmlFor = propVal;
1492
- break;
1493
- default:
1494
- props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
1495
- }
1489
+ if (propName === "key")
1490
+ key = propVal;
1491
+ else if (propName === "namespace")
1492
+ namespace = namespace ?? propVal;
1493
+ else
1494
+ props[propName] = propVal;
1496
1495
  }
1497
1496
  }
1498
1497
  const c = tagName.charCodeAt(0);
@@ -3798,6 +3797,10 @@ function check(_app) {
3798
3797
  async function test(_opts) {
3799
3798
  return null;
3800
3799
  }
3800
+ function collectIterBindings() {
3801
+ console.warn("collectIterBindings is a no-op in the core tutuca build; use the tutuca-dev build for a functional implementation");
3802
+ return [];
3803
+ }
3801
3804
  function tutuca(nodeOrSelector) {
3802
3805
  const rootNode = typeof nodeOrSelector === "string" ? document.querySelector(nodeOrSelector) : nodeOrSelector;
3803
3806
  const comps = new Components;
@@ -3814,6 +3817,7 @@ export {
3814
3817
  html,
3815
3818
  css,
3816
3819
  component,
3820
+ collectIterBindings,
3817
3821
  check,
3818
3822
  SEQ_INFO,
3819
3823
  ParseContext,
package/dist/tutuca.js CHANGED
@@ -5545,40 +5545,49 @@ class RequestHandler {
5545
5545
  }
5546
5546
 
5547
5547
  // src/vdom.js
5548
- var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
5549
5548
  var HTML_NS = "http://www.w3.org/1999/xhtml";
5550
5549
  var isNamespaced = (node) => {
5551
5550
  const ns = node.namespaceURI;
5552
5551
  return ns !== null && ns !== HTML_NS;
5553
5552
  };
5554
- function applyProperties(node, props, previous) {
5553
+ var NEVER_ASSIGN = new Set([
5554
+ "width",
5555
+ "height",
5556
+ "href",
5557
+ "list",
5558
+ "form",
5559
+ "tabIndex",
5560
+ "download",
5561
+ "rowSpan",
5562
+ "colSpan",
5563
+ "role",
5564
+ "popover"
5565
+ ]);
5566
+ function applyProperties(node, props, _previous) {
5555
5567
  const namespaced = isNamespaced(node);
5556
- for (const propName in props) {
5557
- const propValue = props[propName];
5558
- if (propValue === undefined)
5559
- removeProperty(node, propName, previous);
5560
- else if (propName === "dangerouslySetInnerHTML")
5561
- node.innerHTML = propValue.__html ?? "";
5562
- else if (propName === "className")
5563
- node.setAttribute("class", propValue);
5564
- else if (namespaced || isHtmlAttribute(propName))
5565
- node.setAttribute(propName, propValue);
5568
+ for (const name in props)
5569
+ setProp2(node, name, props[name], namespaced);
5570
+ }
5571
+ function setProp2(node, name, value, namespaced) {
5572
+ if (name === "dangerouslySetInnerHTML") {
5573
+ if (value === undefined)
5574
+ node.replaceChildren();
5566
5575
  else
5567
- node[propName] = propValue;
5568
- }
5569
- }
5570
- function removeProperty(node, propName, previous) {
5571
- const previousValue = previous[propName];
5572
- if (propName === "dangerouslySetInnerHTML")
5573
- node.replaceChildren();
5574
- else if (propName === "className")
5575
- node.removeAttribute("class");
5576
- else if (propName === "htmlFor")
5577
- node.removeAttribute("for");
5578
- else if (isNamespaced(node) || typeof previousValue === "string" || isHtmlAttribute(propName))
5579
- node.removeAttribute(propName);
5576
+ node.innerHTML = value.__html ?? "";
5577
+ return;
5578
+ }
5579
+ if (typeof value === "function")
5580
+ return;
5581
+ if (!namespaced && !NEVER_ASSIGN.has(name) && name in node) {
5582
+ try {
5583
+ node[name] = value == null ? "" : value;
5584
+ return;
5585
+ } catch {}
5586
+ }
5587
+ if (value == null || value === false && name[4] !== "-")
5588
+ node.removeAttribute(name);
5580
5589
  else
5581
- node[propName] = null;
5590
+ node.setAttribute(name, value);
5582
5591
  }
5583
5592
 
5584
5593
  class VBase {
@@ -5850,22 +5859,12 @@ function h(tagName, properties, children, namespace) {
5850
5859
  if (properties) {
5851
5860
  for (const propName in properties) {
5852
5861
  const propVal = properties[propName];
5853
- switch (propName) {
5854
- case "key":
5855
- key = propVal;
5856
- break;
5857
- case "namespace":
5858
- namespace = namespace ?? propVal;
5859
- break;
5860
- case "class":
5861
- props.className = propVal;
5862
- break;
5863
- case "for":
5864
- props.htmlFor = propVal;
5865
- break;
5866
- default:
5867
- props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
5868
- }
5862
+ if (propName === "key")
5863
+ key = propVal;
5864
+ else if (propName === "namespace")
5865
+ namespace = namespace ?? propVal;
5866
+ else
5867
+ props[propName] = propVal;
5869
5868
  }
5870
5869
  }
5871
5870
  const c = tagName.charCodeAt(0);
@@ -8156,6 +8155,10 @@ function check(_app) {
8156
8155
  async function test(_opts) {
8157
8156
  return null;
8158
8157
  }
8158
+ function collectIterBindings() {
8159
+ console.warn("collectIterBindings is a no-op in the core tutuca build; use the tutuca-dev build for a functional implementation");
8160
+ return [];
8161
+ }
8159
8162
  function tutuca(nodeOrSelector) {
8160
8163
  const rootNode = typeof nodeOrSelector === "string" ? document.querySelector(nodeOrSelector) : nodeOrSelector;
8161
8164
  const comps = new Components;
@@ -8206,6 +8209,7 @@ export {
8206
8209
  fromJS,
8207
8210
  css,
8208
8211
  component,
8212
+ collectIterBindings,
8209
8213
  check,
8210
8214
  Stack,
8211
8215
  Set2 as Set,