tutuca 0.9.67 → 0.9.69

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));
5493
+ }
5494
+ if (!applyValue && source.tag === "SELECT" && target.attrs.value !== undefined) {
5495
+ pendingValue = target.attrs.value;
5496
+ applyValue = true;
5464
5497
  }
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);
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
  }
@@ -5782,16 +5833,16 @@ function parseXOpVal(opName, value, px, parserFn) {
5782
5833
  return val;
5783
5834
  }
5784
5835
  function processXExtras(node, attrs, opName, startIdx, px) {
5785
- const consumed = X_OP_CONSUMED[opName];
5786
- const wrappable = X_OP_WRAPPABLE.has(opName);
5836
+ const { consumed, wrappable } = X_OPS[opName];
5787
5837
  const wrappers = [];
5788
5838
  for (let i = startIdx;i < attrs.length; i++) {
5789
5839
  const a = attrs[i];
5790
5840
  const aName = a.name;
5791
5841
  if (consumed.has(aName))
5792
5842
  continue;
5793
- if (wrappable && X_ATTR_WRAPPERS[aName]) {
5794
- wrappers.push([X_ATTR_WRAPPERS[aName], vp.parseBool(a.value, px)]);
5843
+ const wrapper = wrappable ? X_OPS[aName]?.wrapper : null;
5844
+ if (wrapper) {
5845
+ wrappers.push([wrapper, vp.parseBool(a.value, px)]);
5795
5846
  continue;
5796
5847
  }
5797
5848
  const issueInfo = { op: opName, name: aName, value: a.value };
@@ -5827,6 +5878,12 @@ function makeWrapperNode(data, px) {
5827
5878
  }
5828
5879
  return node;
5829
5880
  }
5881
+ function dynRenderStep(comp, name, key) {
5882
+ const p = resolveDynProducer(comp, name);
5883
+ if (!p)
5884
+ return null;
5885
+ return key === undefined ? new DynStep(p.producerCompId, p.producerSteps) : new DynEachStep(p.producerCompId, p.producerSteps, key);
5886
+ }
5830
5887
 
5831
5888
  class IterInfo {
5832
5889
  constructor(val, whenVal, loopWithVal, enrichWithVal) {
@@ -5843,6 +5900,9 @@ class IterInfo {
5843
5900
  return { seq, filter, loopWith, enricher };
5844
5901
  }
5845
5902
  }
5903
+ function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
5904
+ return { consumed: new Set(consumed), wrappable, wrapper };
5905
+ }
5846
5906
 
5847
5907
  class ParseContext {
5848
5908
  constructor(document2, Text, Comment, nodes, events, macroNodes, frame, parent) {
@@ -5916,29 +5976,29 @@ class ParseContext {
5916
5976
  console.warn(`tutuca parse issue [${kind}]`, info);
5917
5977
  }
5918
5978
  }
5979
+ function trimEdgeWhite(node) {
5980
+ if (!node.isWhiteSpace?.())
5981
+ return false;
5982
+ node.condenseWhiteSpace();
5983
+ return true;
5984
+ }
5919
5985
  function condenseChildsWhites(childs) {
5920
5986
  if (childs.length === 0)
5921
5987
  return childs;
5922
- let changed = false;
5923
- if (childs[0].isWhiteSpace?.()) {
5924
- childs[0].condenseWhiteSpace();
5925
- changed = true;
5926
- }
5927
5988
  const last = childs.length - 1;
5928
- if (last > 0 && childs[last].isWhiteSpace?.()) {
5929
- childs[last].condenseWhiteSpace();
5930
- changed = true;
5931
- }
5989
+ let emptied = trimEdgeWhite(childs[0]);
5990
+ if (last > 0 && trimEdgeWhite(childs[last]))
5991
+ emptied = true;
5932
5992
  for (let i = 1;i < last; i++) {
5933
5993
  const cur = childs[i];
5934
- if (cur.isWhiteSpace?.() && cur.hasNewLine()) {
5935
- const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
5936
- cur.condenseWhiteSpace(bothBlock ? "" : " ");
5937
- if (bothBlock)
5938
- changed = true;
5939
- }
5994
+ if (!(cur.isWhiteSpace?.() && cur.hasNewLine()))
5995
+ continue;
5996
+ const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
5997
+ cur.condenseWhiteSpace(bothBlock ? "" : " ");
5998
+ if (bothBlock)
5999
+ emptied = true;
5940
6000
  }
5941
- return changed ? childs.filter((c) => !(c instanceof TextNode && c.val === "")) : childs;
6001
+ return emptied ? childs.filter((c) => !isEmptyText(c)) : childs;
5942
6002
  }
5943
6003
 
5944
6004
  class NodeEvents {
@@ -5994,10 +6054,10 @@ function compileModifiers(eventName, names) {
5994
6054
  return w(this, f, args, ctx);
5995
6055
  };
5996
6056
  }
5997
- var TextNode, CommentNode, ChildsNode, DomNode, FragmentNode, maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs), VALID_NODE_RE, ANode, MacroNode, RenderViewId, RenderNode, RenderItNode, RenderEachNode, RenderTextNode, RenderOnceNode, WrapperNode, ShowNode, HideNode, PushViewNameNode, SlotNode, ScopeNode, EachNode, filterAlwaysTrue = (_v, _k, _seq) => true, nullLoopWith = (seq) => ({ iterData: { seq } }), X_OP_CONSUMED, X_OP_WRAPPABLE, X_ATTR_WRAPPERS, WRAPPER_NODES, _htmlBlockTags = "ADDRESS,ARTICLE,ASIDE,BLOCKQUOTE,CAPTION,COL,COLGROUP,DETAILS,DIALOG,DIV,DD,DL,DT,FIELDSET,FIGCAPTION,FIGURE,FOOTER,FORM,H1,H2,H3,H4,H5,H6,HEADER,HGROUP,HR,LEGEND,LI,MAIN,MENU,NAV,OL,P,PRE,SECTION,SUMMARY,TABLE,TBODY,TD,TFOOT,TH,THEAD,TR,UL", HTML_BLOCK_TAGS, isBlockDomNode = (n) => {
6057
+ var TextNode, CommentNode, ChildsNode, DomNode, FragmentNode, maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs), VALID_NODE_RE, ANode, MacroNode, RenderViewId, RenderNode, RenderItNode, RenderEachNode, RenderTextNode, RenderOnceNode, WrapperNode, ShowNode, HideNode, PushViewNameNode, SlotNode, ScopeNode, EachNode, filterAlwaysTrue = (_v, _k, _seq) => true, nullLoopWith = (seq) => ({ iterData: { seq } }), X_OPS, WRAPPER_NODES, _htmlBlockTags = "ADDRESS,ARTICLE,ASIDE,BLOCKQUOTE,CAPTION,COL,COLGROUP,DETAILS,DIALOG,DIV,DD,DL,DT,FIELDSET,FIGCAPTION,FIGURE,FOOTER,FORM,H1,H2,H3,H4,H5,H6,HEADER,HGROUP,HR,LEGEND,LI,MAIN,MENU,NAV,OL,P,PRE,SECTION,SUMMARY,TABLE,TBODY,TD,TFOOT,TH,THEAD,TR,UL", HTML_BLOCK_TAGS, isBlockDomNode = (n) => {
5998
6058
  const node = n instanceof FragmentNode ? n.childs[0] : n;
5999
6059
  return node instanceof DomNode && HTML_BLOCK_TAGS.has(node.tagName);
6000
- }, isMac, fwdIfCtxPred = (pred) => (w) => (that, f, args, ctx) => pred(ctx) ? w(that, f, args, ctx) : that, fwdIfKey = (keyName) => fwdIfCtxPred((ctx) => ctx.e.key === keyName), fwdCtrl, fwdMeta, fwdAlt, metaWraps, MOD_WRAPPERS_BY_EVENT, identityModifierWrapper = (f, _ctx) => f;
6060
+ }, isEmptyText = (c) => c instanceof TextNode && c.val === "", isMac, fwdIfCtxPred = (pred) => (w) => (that, f, args, ctx) => pred(ctx) ? w(that, f, args, ctx) : that, fwdIfKey = (keyName) => fwdIfCtxPred((ctx) => ctx.e.key === keyName), fwdCtrl, fwdMeta, fwdAlt, metaWraps, MOD_WRAPPERS_BY_EVENT, identityModifierWrapper = (f, _ctx) => f;
6001
6061
  var init_anode = __esm(() => {
6002
6062
  init_attribute();
6003
6063
  init_path();
@@ -6201,10 +6261,8 @@ var init_anode = __esm(() => {
6201
6261
  return rx.renderIt(newStack, this, "", this.viewId);
6202
6262
  }
6203
6263
  toPathStep(ctx) {
6204
- if (this.val instanceof DynVal) {
6205
- const p = resolveDynProducer(ctx.comp, this.val.name);
6206
- return p ? new DynStep(p.producerCompId, p.producerSteps) : null;
6207
- }
6264
+ if (this.val instanceof DynVal)
6265
+ return dynRenderStep(ctx.comp, this.val.name);
6208
6266
  return super.toPathStep(ctx);
6209
6267
  }
6210
6268
  };
@@ -6219,10 +6277,8 @@ var init_anode = __esm(() => {
6219
6277
  return null;
6220
6278
  const nextNode = next.resolveNode();
6221
6279
  if (nextNode instanceof EachNode && next.hasKey) {
6222
- if (nextNode.val instanceof DynVal) {
6223
- const p = resolveDynProducer(ctx.comp, nextNode.val.name);
6224
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, next.key) : null;
6225
- }
6280
+ if (nextNode.val instanceof DynVal)
6281
+ return dynRenderStep(ctx.comp, nextNode.val.name, next.key);
6226
6282
  return new EachRenderItStep(nextNode.val.name, next.key);
6227
6283
  }
6228
6284
  return null;
@@ -6237,12 +6293,8 @@ var init_anode = __esm(() => {
6237
6293
  return rx.renderEach(stack, this.iterInfo, this, this.viewId);
6238
6294
  }
6239
6295
  toPathStep(ctx) {
6240
- if (this.val instanceof DynVal) {
6241
- if (!ctx.hasKey)
6242
- return null;
6243
- const p = resolveDynProducer(ctx.comp, this.val.name);
6244
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, ctx.key) : null;
6245
- }
6296
+ if (this.val instanceof DynVal)
6297
+ return ctx.hasKey ? dynRenderStep(ctx.comp, this.val.name, ctx.key) : null;
6246
6298
  return super.toPathStep(ctx);
6247
6299
  }
6248
6300
  static parse(px, vp2, s, as, attrs) {
@@ -6345,17 +6397,15 @@ var init_anode = __esm(() => {
6345
6397
  }
6346
6398
  static register = true;
6347
6399
  };
6348
- X_OP_CONSUMED = {
6349
- slot: new Set,
6350
- text: new Set,
6351
- render: new Set(["as"]),
6352
- "render-it": new Set(["as"]),
6353
- "render-each": new Set(["as", "when", "loop-with"]),
6354
- show: new Set,
6355
- hide: new Set
6356
- };
6357
- X_OP_WRAPPABLE = new Set(["text", "render", "render-it", "render-each"]);
6358
- X_ATTR_WRAPPERS = { show: ShowNode, hide: HideNode };
6400
+ X_OPS = {
6401
+ slot: xOp(),
6402
+ text: xOp([], { wrappable: true }),
6403
+ render: xOp(["as"], { wrappable: true }),
6404
+ "render-it": xOp(["as"], { wrappable: true }),
6405
+ "render-each": xOp(["as", "when", "loop-with"], { wrappable: true }),
6406
+ show: xOp([], { wrapper: ShowNode }),
6407
+ hide: xOp([], { wrapper: HideNode })
6408
+ };
6359
6409
  WRAPPER_NODES = {
6360
6410
  slot: SlotNode,
6361
6411
  show: ShowNode,
@@ -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));
4892
+ }
4893
+ if (!applyValue && source.tag === "SELECT" && target.attrs.value !== undefined) {
4894
+ pendingValue = target.attrs.value;
4895
+ applyValue = true;
4851
4896
  }
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);
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);
@@ -5209,16 +5264,16 @@ function parseXOpVal(opName, value, px, parserFn) {
5209
5264
  return val;
5210
5265
  }
5211
5266
  function processXExtras(node, attrs, opName, startIdx, px) {
5212
- const consumed = X_OP_CONSUMED[opName];
5213
- const wrappable = X_OP_WRAPPABLE.has(opName);
5267
+ const { consumed, wrappable } = X_OPS[opName];
5214
5268
  const wrappers = [];
5215
5269
  for (let i = startIdx;i < attrs.length; i++) {
5216
5270
  const a = attrs[i];
5217
5271
  const aName = a.name;
5218
5272
  if (consumed.has(aName))
5219
5273
  continue;
5220
- if (wrappable && X_ATTR_WRAPPERS[aName]) {
5221
- wrappers.push([X_ATTR_WRAPPERS[aName], vp.parseBool(a.value, px)]);
5274
+ const wrapper = wrappable ? X_OPS[aName]?.wrapper : null;
5275
+ if (wrapper) {
5276
+ wrappers.push([wrapper, vp.parseBool(a.value, px)]);
5222
5277
  continue;
5223
5278
  }
5224
5279
  const issueInfo = { op: opName, name: aName, value: a.value };
@@ -5310,6 +5365,12 @@ class RenderViewId extends ANode {
5310
5365
  }
5311
5366
  setDataAttr(_key, _val) {}
5312
5367
  }
5368
+ function dynRenderStep(comp, name, key) {
5369
+ const p = resolveDynProducer(comp, name);
5370
+ if (!p)
5371
+ return null;
5372
+ return key === undefined ? new DynStep(p.producerCompId, p.producerSteps) : new DynEachStep(p.producerCompId, p.producerSteps, key);
5373
+ }
5313
5374
 
5314
5375
  class RenderNode extends RenderViewId {
5315
5376
  render(stack, rx) {
@@ -5317,10 +5378,8 @@ class RenderNode extends RenderViewId {
5317
5378
  return rx.renderIt(newStack, this, "", this.viewId);
5318
5379
  }
5319
5380
  toPathStep(ctx) {
5320
- if (this.val instanceof DynVal) {
5321
- const p = resolveDynProducer(ctx.comp, this.val.name);
5322
- return p ? new DynStep(p.producerCompId, p.producerSteps) : null;
5323
- }
5381
+ if (this.val instanceof DynVal)
5382
+ return dynRenderStep(ctx.comp, this.val.name);
5324
5383
  return super.toPathStep(ctx);
5325
5384
  }
5326
5385
  }
@@ -5336,10 +5395,8 @@ class RenderItNode extends RenderViewId {
5336
5395
  return null;
5337
5396
  const nextNode = next.resolveNode();
5338
5397
  if (nextNode instanceof EachNode && next.hasKey) {
5339
- if (nextNode.val instanceof DynVal) {
5340
- const p = resolveDynProducer(ctx.comp, nextNode.val.name);
5341
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, next.key) : null;
5342
- }
5398
+ if (nextNode.val instanceof DynVal)
5399
+ return dynRenderStep(ctx.comp, nextNode.val.name, next.key);
5343
5400
  return new EachRenderItStep(nextNode.val.name, next.key);
5344
5401
  }
5345
5402
  return null;
@@ -5355,12 +5412,8 @@ class RenderEachNode extends RenderViewId {
5355
5412
  return rx.renderEach(stack, this.iterInfo, this, this.viewId);
5356
5413
  }
5357
5414
  toPathStep(ctx) {
5358
- if (this.val instanceof DynVal) {
5359
- if (!ctx.hasKey)
5360
- return null;
5361
- const p = resolveDynProducer(ctx.comp, this.val.name);
5362
- return p ? new DynEachStep(p.producerCompId, p.producerSteps, ctx.key) : null;
5363
- }
5415
+ if (this.val instanceof DynVal)
5416
+ return ctx.hasKey ? dynRenderStep(ctx.comp, this.val.name, ctx.key) : null;
5364
5417
  return super.toPathStep(ctx);
5365
5418
  }
5366
5419
  static parse(px, vp2, s, as, attrs) {
@@ -5490,17 +5543,18 @@ class IterInfo {
5490
5543
  }
5491
5544
  var filterAlwaysTrue = (_v, _k, _seq) => true;
5492
5545
  var nullLoopWith = (seq) => ({ iterData: { seq } });
5493
- var X_OP_CONSUMED = {
5494
- slot: new Set,
5495
- text: new Set,
5496
- render: new Set(["as"]),
5497
- "render-it": new Set(["as"]),
5498
- "render-each": new Set(["as", "when", "loop-with"]),
5499
- show: new Set,
5500
- hide: new Set
5501
- };
5502
- var X_OP_WRAPPABLE = new Set(["text", "render", "render-it", "render-each"]);
5503
- var X_ATTR_WRAPPERS = { show: ShowNode, hide: HideNode };
5546
+ function xOp(consumed = [], { wrappable = false, wrapper = null } = {}) {
5547
+ return { consumed: new Set(consumed), wrappable, wrapper };
5548
+ }
5549
+ var X_OPS = {
5550
+ slot: xOp(),
5551
+ text: xOp([], { wrappable: true }),
5552
+ render: xOp(["as"], { wrappable: true }),
5553
+ "render-it": xOp(["as"], { wrappable: true }),
5554
+ "render-each": xOp(["as", "when", "loop-with"], { wrappable: true }),
5555
+ show: xOp([], { wrapper: ShowNode }),
5556
+ hide: xOp([], { wrapper: HideNode })
5557
+ };
5504
5558
  var WRAPPER_NODES = {
5505
5559
  slot: SlotNode,
5506
5560
  show: ShowNode,
@@ -5588,29 +5642,30 @@ var isBlockDomNode = (n) => {
5588
5642
  const node = n instanceof FragmentNode ? n.childs[0] : n;
5589
5643
  return node instanceof DomNode && HTML_BLOCK_TAGS.has(node.tagName);
5590
5644
  };
5645
+ var isEmptyText = (c) => c instanceof TextNode && c.val === "";
5646
+ function trimEdgeWhite(node) {
5647
+ if (!node.isWhiteSpace?.())
5648
+ return false;
5649
+ node.condenseWhiteSpace();
5650
+ return true;
5651
+ }
5591
5652
  function condenseChildsWhites(childs) {
5592
5653
  if (childs.length === 0)
5593
5654
  return childs;
5594
- let changed = false;
5595
- if (childs[0].isWhiteSpace?.()) {
5596
- childs[0].condenseWhiteSpace();
5597
- changed = true;
5598
- }
5599
5655
  const last = childs.length - 1;
5600
- if (last > 0 && childs[last].isWhiteSpace?.()) {
5601
- childs[last].condenseWhiteSpace();
5602
- changed = true;
5603
- }
5656
+ let emptied = trimEdgeWhite(childs[0]);
5657
+ if (last > 0 && trimEdgeWhite(childs[last]))
5658
+ emptied = true;
5604
5659
  for (let i = 1;i < last; i++) {
5605
5660
  const cur = childs[i];
5606
- if (cur.isWhiteSpace?.() && cur.hasNewLine()) {
5607
- const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
5608
- cur.condenseWhiteSpace(bothBlock ? "" : " ");
5609
- if (bothBlock)
5610
- changed = true;
5611
- }
5661
+ if (!(cur.isWhiteSpace?.() && cur.hasNewLine()))
5662
+ continue;
5663
+ const bothBlock = isBlockDomNode(childs[i - 1]) && isBlockDomNode(childs[i + 1]);
5664
+ cur.condenseWhiteSpace(bothBlock ? "" : " ");
5665
+ if (bothBlock)
5666
+ emptied = true;
5612
5667
  }
5613
- return changed ? childs.filter((c) => !(c instanceof TextNode && c.val === "")) : childs;
5668
+ return emptied ? childs.filter((c) => !isEmptyText(c)) : childs;
5614
5669
  }
5615
5670
 
5616
5671
  class View {