tutuca 0.9.67 → 0.9.68

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.
@@ -5367,7 +5367,11 @@ var init_attribute = __esm(() => {
5367
5367
  });
5368
5368
 
5369
5369
  // src/vdom.js
5370
- function applyProperties(node, props, _previous) {
5370
+ function childOpts(vnode, ns, opts) {
5371
+ const target = ns === SVG_NS && isForeignObject(vnode.tag) ? null : ns;
5372
+ return target === (opts.namespace ?? null) ? opts : { ...opts, namespace: target };
5373
+ }
5374
+ function applyProperties(node, props) {
5371
5375
  const namespaced = isNamespaced(node);
5372
5376
  for (const name in props)
5373
5377
  setProp2(node, name, props[name], namespaced);
@@ -5376,8 +5380,11 @@ function setProp2(node, name, value, namespaced) {
5376
5380
  if (name === "dangerouslySetInnerHTML") {
5377
5381
  if (value === undefined)
5378
5382
  node.replaceChildren();
5379
- else
5380
- node.innerHTML = value.__html ?? "";
5383
+ else {
5384
+ const html = value.__html ?? "";
5385
+ if (html !== node.innerHTML)
5386
+ node.innerHTML = html;
5387
+ }
5381
5388
  return;
5382
5389
  }
5383
5390
  if (typeof value === "function")
@@ -5393,6 +5400,13 @@ function setProp2(node, name, value, namespaced) {
5393
5400
  else
5394
5401
  node.setAttribute(name, value);
5395
5402
  }
5403
+ function applyValueLast(node, value) {
5404
+ if (node.tagName === "PROGRESS" && (value == null || value === 0)) {
5405
+ node.removeAttribute("value");
5406
+ } else {
5407
+ setProp2(node, "value", value, isNamespaced(node));
5408
+ }
5409
+ }
5396
5410
 
5397
5411
  class VBase {
5398
5412
  }
@@ -5454,18 +5468,37 @@ function morphNode(domNode, source, target, opts) {
5454
5468
  }
5455
5469
  if (type === 1 && source.isSameKind(target)) {
5456
5470
  const propsDiff = diffProps(source.attrs, target.attrs);
5457
- const isSelect = source.tag === "SELECT";
5471
+ let pendingValue;
5472
+ let pendingChecked;
5473
+ let applyValue = false;
5474
+ let applyChecked = false;
5458
5475
  if (propsDiff) {
5459
- if (isSelect && "value" in propsDiff) {
5460
- const { value: _v, ...rest } = propsDiff;
5461
- applyProperties(domNode, rest, source.attrs);
5476
+ if ("value" in propsDiff || "checked" in propsDiff) {
5477
+ const { value, checked, ...rest } = propsDiff;
5478
+ applyProperties(domNode, rest);
5479
+ if ("value" in propsDiff) {
5480
+ pendingValue = value;
5481
+ applyValue = true;
5482
+ }
5483
+ if ("checked" in propsDiff) {
5484
+ pendingChecked = checked;
5485
+ applyChecked = true;
5486
+ }
5462
5487
  } else
5463
- applyProperties(domNode, propsDiff, source.attrs);
5488
+ applyProperties(domNode, propsDiff);
5489
+ }
5490
+ if (!target.attrs.dangerouslySetInnerHTML) {
5491
+ const ns = effectiveNs(target, opts);
5492
+ morphChildren(domNode, source.childs, target.childs, childOpts(target, ns, opts));
5464
5493
  }
5465
- if (!target.attrs.dangerouslySetInnerHTML)
5466
- morphChildren(domNode, source.childs, target.childs, opts);
5467
- if (isSelect && target.attrs.value !== undefined)
5468
- applyProperties(domNode, { value: target.attrs.value }, source.attrs);
5494
+ if (!applyValue && source.tag === "SELECT" && target.attrs.value !== undefined) {
5495
+ pendingValue = target.attrs.value;
5496
+ applyValue = true;
5497
+ }
5498
+ if (applyValue)
5499
+ applyValueLast(domNode, pendingValue);
5500
+ if (applyChecked)
5501
+ setProp2(domNode, "checked", pendingChecked, false);
5469
5502
  return domNode;
5470
5503
  }
5471
5504
  if (type === 11) {
@@ -5569,16 +5602,26 @@ function h(tagName, properties, children, namespace) {
5569
5602
  props[propName] = propVal;
5570
5603
  }
5571
5604
  }
5605
+ if (namespace == null) {
5606
+ const lower = tagName.toLowerCase();
5607
+ if (lower === "svg") {
5608
+ namespace = SVG_NS;
5609
+ tagName = "svg";
5610
+ } else if (lower === "math") {
5611
+ namespace = MATH_NS;
5612
+ tagName = "math";
5613
+ }
5614
+ }
5572
5615
  const c = tagName.charCodeAt(0);
5573
- const tag = namespace == null && c >= 97 && c <= 122 ? tagName.toUpperCase() : tagName;
5616
+ const tag = namespace == null && c >= 97 && c <= 122 && tagName === tagName.toLowerCase() ? tagName.toUpperCase() : tagName;
5574
5617
  const normalizedChildren = [];
5575
5618
  addChild(normalizedChildren, children);
5576
5619
  return new VNode2(tag, props, normalizedChildren, key, namespace);
5577
5620
  }
5578
- var HTML_NS = "http://www.w3.org/1999/xhtml", isNamespaced = (node) => {
5621
+ var HTML_NS = "http://www.w3.org/1999/xhtml", SVG_NS = "http://www.w3.org/2000/svg", MATH_NS = "http://www.w3.org/1998/Math/MathML", isNamespaced = (node) => {
5579
5622
  const ns = node.namespaceURI;
5580
5623
  return ns !== null && ns !== HTML_NS;
5581
- }, NEVER_ASSIGN, getKey = (child) => child instanceof VNode2 ? child.key : undefined, isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function", VText, VComment, VFragment, VNode2;
5624
+ }, isForeignObject = (tag) => tag.length === 13 && tag.toLowerCase() === "foreignobject", effectiveNs = (vnode, opts) => vnode.namespace ?? opts.namespace ?? null, NEVER_ASSIGN, getKey = (child) => child instanceof VNode2 ? child.key : undefined, isIterable = (obj) => obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function", VText, VComment, VFragment, VNode2;
5582
5625
  var init_vdom = __esm(() => {
5583
5626
  NEVER_ASSIGN = new Set([
5584
5627
  "width",
@@ -5676,15 +5719,23 @@ var init_vdom = __esm(() => {
5676
5719
  }
5677
5720
  toDom(opts) {
5678
5721
  const doc = opts.document;
5679
- const node = this.namespace === null ? doc.createElement(this.tag) : doc.createElementNS(this.namespace, this.tag);
5680
- if (this.tag === "SELECT" && "value" in this.attrs) {
5681
- const { value, ...rest } = this.attrs;
5682
- applyProperties(node, rest, {});
5683
- appendChildNodes(node, this.childs, opts);
5684
- applyProperties(node, { value }, {});
5722
+ const ns = effectiveNs(this, opts);
5723
+ const tag = ns !== null && this.tag === this.tag.toUpperCase() ? this.tag.toLowerCase() : this.tag;
5724
+ const attrs = this.attrs;
5725
+ const createOpts = attrs.is != null ? { is: attrs.is } : undefined;
5726
+ const node = ns === null ? doc.createElement(tag, createOpts) : doc.createElementNS(ns, tag, createOpts);
5727
+ const cOpts = childOpts(this, ns, opts);
5728
+ if ("value" in attrs || "checked" in attrs) {
5729
+ const { value, checked, ...rest } = attrs;
5730
+ applyProperties(node, rest);
5731
+ appendChildNodes(node, this.childs, cOpts);
5732
+ if (value !== undefined)
5733
+ applyValueLast(node, value);
5734
+ if (checked !== undefined)
5735
+ setProp2(node, "checked", checked, false);
5685
5736
  } else {
5686
- applyProperties(node, this.attrs, {});
5687
- appendChildNodes(node, this.childs, opts);
5737
+ applyProperties(node, attrs);
5738
+ appendChildNodes(node, this.childs, cOpts);
5688
5739
  }
5689
5740
  return node;
5690
5741
  }
@@ -4635,10 +4635,18 @@ class RequestHandler {
4635
4635
 
4636
4636
  // src/vdom.js
4637
4637
  var HTML_NS = "http://www.w3.org/1999/xhtml";
4638
+ var SVG_NS = "http://www.w3.org/2000/svg";
4639
+ var MATH_NS = "http://www.w3.org/1998/Math/MathML";
4638
4640
  var isNamespaced = (node) => {
4639
4641
  const ns = node.namespaceURI;
4640
4642
  return ns !== null && ns !== HTML_NS;
4641
4643
  };
4644
+ var isForeignObject = (tag) => tag.length === 13 && tag.toLowerCase() === "foreignobject";
4645
+ var effectiveNs = (vnode, opts) => vnode.namespace ?? opts.namespace ?? null;
4646
+ function childOpts(vnode, ns, opts) {
4647
+ const target = ns === SVG_NS && isForeignObject(vnode.tag) ? null : ns;
4648
+ return target === (opts.namespace ?? null) ? opts : { ...opts, namespace: target };
4649
+ }
4642
4650
  var NEVER_ASSIGN = new Set([
4643
4651
  "width",
4644
4652
  "height",
@@ -4652,7 +4660,7 @@ var NEVER_ASSIGN = new Set([
4652
4660
  "role",
4653
4661
  "popover"
4654
4662
  ]);
4655
- function applyProperties(node, props, _previous) {
4663
+ function applyProperties(node, props) {
4656
4664
  const namespaced = isNamespaced(node);
4657
4665
  for (const name in props)
4658
4666
  setProp(node, name, props[name], namespaced);
@@ -4661,8 +4669,11 @@ function setProp(node, name, value, namespaced) {
4661
4669
  if (name === "dangerouslySetInnerHTML") {
4662
4670
  if (value === undefined)
4663
4671
  node.replaceChildren();
4664
- else
4665
- node.innerHTML = value.__html ?? "";
4672
+ else {
4673
+ const html = value.__html ?? "";
4674
+ if (html !== node.innerHTML)
4675
+ node.innerHTML = html;
4676
+ }
4666
4677
  return;
4667
4678
  }
4668
4679
  if (typeof value === "function")
@@ -4678,6 +4689,13 @@ function setProp(node, name, value, namespaced) {
4678
4689
  else
4679
4690
  node.setAttribute(name, value);
4680
4691
  }
4692
+ function applyValueLast(node, value) {
4693
+ if (node.tagName === "PROGRESS" && (value == null || value === 0)) {
4694
+ node.removeAttribute("value");
4695
+ } else {
4696
+ setProp(node, "value", value, isNamespaced(node));
4697
+ }
4698
+ }
4681
4699
 
4682
4700
  class VBase {
4683
4701
  }
@@ -4796,15 +4814,23 @@ class VNode extends VBase {
4796
4814
  }
4797
4815
  toDom(opts) {
4798
4816
  const doc = opts.document;
4799
- const node = this.namespace === null ? doc.createElement(this.tag) : doc.createElementNS(this.namespace, this.tag);
4800
- if (this.tag === "SELECT" && "value" in this.attrs) {
4801
- const { value, ...rest } = this.attrs;
4802
- applyProperties(node, rest, {});
4803
- appendChildNodes(node, this.childs, opts);
4804
- applyProperties(node, { value }, {});
4817
+ const ns = effectiveNs(this, opts);
4818
+ const tag = ns !== null && this.tag === this.tag.toUpperCase() ? this.tag.toLowerCase() : this.tag;
4819
+ const attrs = this.attrs;
4820
+ const createOpts = attrs.is != null ? { is: attrs.is } : undefined;
4821
+ const node = ns === null ? doc.createElement(tag, createOpts) : doc.createElementNS(ns, tag, createOpts);
4822
+ const cOpts = childOpts(this, ns, opts);
4823
+ if ("value" in attrs || "checked" in attrs) {
4824
+ const { value, checked, ...rest } = attrs;
4825
+ applyProperties(node, rest);
4826
+ appendChildNodes(node, this.childs, cOpts);
4827
+ if (value !== undefined)
4828
+ applyValueLast(node, value);
4829
+ if (checked !== undefined)
4830
+ setProp(node, "checked", checked, false);
4805
4831
  } else {
4806
- applyProperties(node, this.attrs, {});
4807
- appendChildNodes(node, this.childs, opts);
4832
+ applyProperties(node, attrs);
4833
+ appendChildNodes(node, this.childs, cOpts);
4808
4834
  }
4809
4835
  return node;
4810
4836
  }
@@ -4841,18 +4867,37 @@ function morphNode(domNode, source, target, opts) {
4841
4867
  }
4842
4868
  if (type3 === 1 && source.isSameKind(target)) {
4843
4869
  const propsDiff = diffProps(source.attrs, target.attrs);
4844
- const isSelect = source.tag === "SELECT";
4870
+ let pendingValue;
4871
+ let pendingChecked;
4872
+ let applyValue = false;
4873
+ let applyChecked = false;
4845
4874
  if (propsDiff) {
4846
- if (isSelect && "value" in propsDiff) {
4847
- const { value: _v, ...rest } = propsDiff;
4848
- applyProperties(domNode, rest, source.attrs);
4875
+ if ("value" in propsDiff || "checked" in propsDiff) {
4876
+ const { value, checked, ...rest } = propsDiff;
4877
+ applyProperties(domNode, rest);
4878
+ if ("value" in propsDiff) {
4879
+ pendingValue = value;
4880
+ applyValue = true;
4881
+ }
4882
+ if ("checked" in propsDiff) {
4883
+ pendingChecked = checked;
4884
+ applyChecked = true;
4885
+ }
4849
4886
  } else
4850
- applyProperties(domNode, propsDiff, source.attrs);
4887
+ applyProperties(domNode, propsDiff);
4888
+ }
4889
+ if (!target.attrs.dangerouslySetInnerHTML) {
4890
+ const ns = effectiveNs(target, opts);
4891
+ morphChildren(domNode, source.childs, target.childs, childOpts(target, ns, opts));
4851
4892
  }
4852
- if (!target.attrs.dangerouslySetInnerHTML)
4853
- morphChildren(domNode, source.childs, target.childs, opts);
4854
- if (isSelect && target.attrs.value !== undefined)
4855
- applyProperties(domNode, { value: target.attrs.value }, source.attrs);
4893
+ if (!applyValue && source.tag === "SELECT" && target.attrs.value !== undefined) {
4894
+ pendingValue = target.attrs.value;
4895
+ applyValue = true;
4896
+ }
4897
+ if (applyValue)
4898
+ applyValueLast(domNode, pendingValue);
4899
+ if (applyChecked)
4900
+ setProp(domNode, "checked", pendingChecked, false);
4856
4901
  return domNode;
4857
4902
  }
4858
4903
  if (type3 === 11) {
@@ -4956,8 +5001,18 @@ function h(tagName, properties, children, namespace) {
4956
5001
  props[propName] = propVal;
4957
5002
  }
4958
5003
  }
5004
+ if (namespace == null) {
5005
+ const lower = tagName.toLowerCase();
5006
+ if (lower === "svg") {
5007
+ namespace = SVG_NS;
5008
+ tagName = "svg";
5009
+ } else if (lower === "math") {
5010
+ namespace = MATH_NS;
5011
+ tagName = "math";
5012
+ }
5013
+ }
4959
5014
  const c = tagName.charCodeAt(0);
4960
- const tag = namespace == null && c >= 97 && c <= 122 ? tagName.toUpperCase() : tagName;
5015
+ const tag = namespace == null && c >= 97 && c <= 122 && tagName === tagName.toLowerCase() ? tagName.toUpperCase() : tagName;
4961
5016
  const normalizedChildren = [];
4962
5017
  addChild(normalizedChildren, children);
4963
5018
  return new VNode(tag, props, normalizedChildren, key, namespace);
@@ -8841,10 +8841,18 @@ class RequestHandler {
8841
8841
 
8842
8842
  // src/vdom.js
8843
8843
  var HTML_NS = "http://www.w3.org/1999/xhtml";
8844
+ var SVG_NS = "http://www.w3.org/2000/svg";
8845
+ var MATH_NS = "http://www.w3.org/1998/Math/MathML";
8844
8846
  var isNamespaced = (node) => {
8845
8847
  const ns = node.namespaceURI;
8846
8848
  return ns !== null && ns !== HTML_NS;
8847
8849
  };
8850
+ var isForeignObject = (tag) => tag.length === 13 && tag.toLowerCase() === "foreignobject";
8851
+ var effectiveNs = (vnode, opts) => vnode.namespace ?? opts.namespace ?? null;
8852
+ function childOpts(vnode, ns, opts) {
8853
+ const target = ns === SVG_NS && isForeignObject(vnode.tag) ? null : ns;
8854
+ return target === (opts.namespace ?? null) ? opts : { ...opts, namespace: target };
8855
+ }
8848
8856
  var NEVER_ASSIGN = new Set([
8849
8857
  "width",
8850
8858
  "height",
@@ -8858,7 +8866,7 @@ var NEVER_ASSIGN = new Set([
8858
8866
  "role",
8859
8867
  "popover"
8860
8868
  ]);
8861
- function applyProperties(node, props, _previous) {
8869
+ function applyProperties(node, props) {
8862
8870
  const namespaced = isNamespaced(node);
8863
8871
  for (const name in props)
8864
8872
  setProp2(node, name, props[name], namespaced);
@@ -8867,8 +8875,11 @@ function setProp2(node, name, value, namespaced) {
8867
8875
  if (name === "dangerouslySetInnerHTML") {
8868
8876
  if (value === undefined)
8869
8877
  node.replaceChildren();
8870
- else
8871
- node.innerHTML = value.__html ?? "";
8878
+ else {
8879
+ const html = value.__html ?? "";
8880
+ if (html !== node.innerHTML)
8881
+ node.innerHTML = html;
8882
+ }
8872
8883
  return;
8873
8884
  }
8874
8885
  if (typeof value === "function")
@@ -8884,6 +8895,13 @@ function setProp2(node, name, value, namespaced) {
8884
8895
  else
8885
8896
  node.setAttribute(name, value);
8886
8897
  }
8898
+ function applyValueLast(node, value) {
8899
+ if (node.tagName === "PROGRESS" && (value == null || value === 0)) {
8900
+ node.removeAttribute("value");
8901
+ } else {
8902
+ setProp2(node, "value", value, isNamespaced(node));
8903
+ }
8904
+ }
8887
8905
 
8888
8906
  class VBase {
8889
8907
  }
@@ -9002,15 +9020,23 @@ class VNode2 extends VBase {
9002
9020
  }
9003
9021
  toDom(opts) {
9004
9022
  const doc = opts.document;
9005
- const node = this.namespace === null ? doc.createElement(this.tag) : doc.createElementNS(this.namespace, this.tag);
9006
- if (this.tag === "SELECT" && "value" in this.attrs) {
9007
- const { value, ...rest } = this.attrs;
9008
- applyProperties(node, rest, {});
9009
- appendChildNodes(node, this.childs, opts);
9010
- applyProperties(node, { value }, {});
9023
+ const ns = effectiveNs(this, opts);
9024
+ const tag = ns !== null && this.tag === this.tag.toUpperCase() ? this.tag.toLowerCase() : this.tag;
9025
+ const attrs = this.attrs;
9026
+ const createOpts = attrs.is != null ? { is: attrs.is } : undefined;
9027
+ const node = ns === null ? doc.createElement(tag, createOpts) : doc.createElementNS(ns, tag, createOpts);
9028
+ const cOpts = childOpts(this, ns, opts);
9029
+ if ("value" in attrs || "checked" in attrs) {
9030
+ const { value, checked, ...rest } = attrs;
9031
+ applyProperties(node, rest);
9032
+ appendChildNodes(node, this.childs, cOpts);
9033
+ if (value !== undefined)
9034
+ applyValueLast(node, value);
9035
+ if (checked !== undefined)
9036
+ setProp2(node, "checked", checked, false);
9011
9037
  } else {
9012
- applyProperties(node, this.attrs, {});
9013
- appendChildNodes(node, this.childs, opts);
9038
+ applyProperties(node, attrs);
9039
+ appendChildNodes(node, this.childs, cOpts);
9014
9040
  }
9015
9041
  return node;
9016
9042
  }
@@ -9047,18 +9073,37 @@ function morphNode(domNode, source, target, opts) {
9047
9073
  }
9048
9074
  if (type3 === 1 && source.isSameKind(target)) {
9049
9075
  const propsDiff = diffProps(source.attrs, target.attrs);
9050
- const isSelect = source.tag === "SELECT";
9076
+ let pendingValue;
9077
+ let pendingChecked;
9078
+ let applyValue = false;
9079
+ let applyChecked = false;
9051
9080
  if (propsDiff) {
9052
- if (isSelect && "value" in propsDiff) {
9053
- const { value: _v, ...rest } = propsDiff;
9054
- applyProperties(domNode, rest, source.attrs);
9081
+ if ("value" in propsDiff || "checked" in propsDiff) {
9082
+ const { value, checked, ...rest } = propsDiff;
9083
+ applyProperties(domNode, rest);
9084
+ if ("value" in propsDiff) {
9085
+ pendingValue = value;
9086
+ applyValue = true;
9087
+ }
9088
+ if ("checked" in propsDiff) {
9089
+ pendingChecked = checked;
9090
+ applyChecked = true;
9091
+ }
9055
9092
  } else
9056
- applyProperties(domNode, propsDiff, source.attrs);
9093
+ applyProperties(domNode, propsDiff);
9094
+ }
9095
+ if (!target.attrs.dangerouslySetInnerHTML) {
9096
+ const ns = effectiveNs(target, opts);
9097
+ morphChildren(domNode, source.childs, target.childs, childOpts(target, ns, opts));
9057
9098
  }
9058
- if (!target.attrs.dangerouslySetInnerHTML)
9059
- morphChildren(domNode, source.childs, target.childs, opts);
9060
- if (isSelect && target.attrs.value !== undefined)
9061
- applyProperties(domNode, { value: target.attrs.value }, source.attrs);
9099
+ if (!applyValue && source.tag === "SELECT" && target.attrs.value !== undefined) {
9100
+ pendingValue = target.attrs.value;
9101
+ applyValue = true;
9102
+ }
9103
+ if (applyValue)
9104
+ applyValueLast(domNode, pendingValue);
9105
+ if (applyChecked)
9106
+ setProp2(domNode, "checked", pendingChecked, false);
9062
9107
  return domNode;
9063
9108
  }
9064
9109
  if (type3 === 11) {
@@ -9162,8 +9207,18 @@ function h(tagName, properties, children, namespace) {
9162
9207
  props[propName] = propVal;
9163
9208
  }
9164
9209
  }
9210
+ if (namespace == null) {
9211
+ const lower = tagName.toLowerCase();
9212
+ if (lower === "svg") {
9213
+ namespace = SVG_NS;
9214
+ tagName = "svg";
9215
+ } else if (lower === "math") {
9216
+ namespace = MATH_NS;
9217
+ tagName = "math";
9218
+ }
9219
+ }
9165
9220
  const c = tagName.charCodeAt(0);
9166
- const tag = namespace == null && c >= 97 && c <= 122 ? tagName.toUpperCase() : tagName;
9221
+ const tag = namespace == null && c >= 97 && c <= 122 && tagName === tagName.toLowerCase() ? tagName.toUpperCase() : tagName;
9167
9222
  const normalizedChildren = [];
9168
9223
  addChild(normalizedChildren, children);
9169
9224
  return new VNode2(tag, props, normalizedChildren, key, namespace);