marko 6.3.25 → 6.3.26

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.
@@ -1364,13 +1364,18 @@ function writeGenerator(state, iter, ref) {
1364
1364
  state.buf.push("(function*(){})()");
1365
1365
  return true;
1366
1366
  }
1367
- state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : "(function*(a,r){yield*a;return r})(");
1367
+ const heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
1368
+ state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : heldReturn ? "(function*(a,r){yield*a;return r.v})(" : "(function*(a,r){yield*a;return r})(");
1368
1369
  if (needsId) {
1369
1370
  const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1370
1371
  state.buf.push(arrayRef.id + "=");
1371
1372
  writeArray(state, yields, arrayRef);
1372
1373
  } else writeArray(state, yields, new Reference(ref, null, state.flush, state.buf.length));
1373
- if (returnValue !== void 0) {
1374
+ if (heldReturn) {
1375
+ const holder = new Reference(ref, null, state.flush, null, nextRefAccess(state));
1376
+ state.buf.push("," + holder.id + "={}");
1377
+ writeProp(state, returnValue, holder, "v");
1378
+ } else if (returnValue !== void 0) {
1374
1379
  const sepIndex = state.buf.push(",") - 1;
1375
1380
  if (writeProp(state, returnValue, ref, "") && isDedupedMember(returnValue)) {
1376
1381
  const retRef = typeof returnValue === "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
@@ -2761,7 +2766,8 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
2761
2766
  return _textarea_value(value);
2762
2767
  }
2763
2768
  function _textarea_value(value) {
2764
- return _escape(normalizeStrAttrValue(value));
2769
+ const escaped = _escape(normalizeStrAttrValue(value));
2770
+ return escaped[0] === "\n" || escaped[0] === "\r" ? "\n" + escaped : escaped;
2765
2771
  }
2766
2772
  function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2767
2773
  if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
package/dist/dom.js CHANGED
@@ -4,7 +4,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
4
4
  else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
5
5
  else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
6
6
  return str;
7
- }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, !0), 1), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
7
+ }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
8
8
  scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
9
9
  }, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), walker = /* @__PURE__ */ document.createTreeWalker(document), walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
10
10
  let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
@@ -20,7 +20,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
20
20
  for (value = 10 * currentMultiplier + value - 107; value--;) walker.parentNode();
21
21
  walker.nextSibling();
22
22
  } else storedMultiplier = currentMultiplier * 10 + value - 117;
23
- }, cloneCache = {}, registeredValues = {}, curRenders, branchesEnabled, embedRenders, readyIds, isResuming, inputType = "", controllableScripts = {}, controllableRenders = {}, _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
23
+ }, registeredValues = {}, curRenders, branchesEnabled, embedRenders, readyIds, isResuming, cloneCache = {}, R = /[^\p{L}\p{N}]/gu, inputType = "", controllableScripts = {}, controllableRenders = {}, _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
24
24
  nodeAccessor = decodeAccessor(nodeAccessor);
25
25
  let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
26
26
  return enableBranches(), (scope, newRenderer, getInput) => {
@@ -33,7 +33,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
33
33
  } else normalizedRenderer?.f && subscribeToScopeSet(normalizedRenderer.e, normalizedRenderer.f, scope[childScopeAccessor]);
34
34
  if (normalizedRenderer) {
35
35
  let childScope = scope[childScopeAccessor], args = getInput?.();
36
- if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
36
+ if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope.a.tagName]), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
37
37
  else {
38
38
  for (let accessor in normalizedRenderer.g) normalizedRenderer.g[accessor](childScope, normalizedRenderer.h[accessor]);
39
39
  if (normalizedRenderer.d) if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
@@ -207,19 +207,6 @@ function handleDelegated(ev) {
207
207
  for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
208
208
  }
209
209
  //#endregion
210
- //#region src/dom/resolve-cursor-position.ts
211
- function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
212
- if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
213
- let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
214
- if (updatedValue.startsWith(before)) return initialPosition;
215
- if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
216
- let count = before.replace(R, "").length, pos = 0;
217
- for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
218
- return pos;
219
- }
220
- return -1;
221
- }
222
- //#endregion
223
210
  //#region src/dom/parse-html.ts
224
211
  function parseHTML(html, ns) {
225
212
  let parser = parsers[ns] ||= document.createElementNS(ns, "template");
@@ -422,57 +409,6 @@ function walk(startNode, walkCodes, branch) {
422
409
  walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
423
410
  }
424
411
  //#endregion
425
- //#region src/dom/renderer.ts
426
- function createBranch($global, renderer, parentScope, parentNode) {
427
- let branch = createScope($global);
428
- return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
429
- }
430
- function setParentBranch(branch, parentBranch) {
431
- parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
432
- }
433
- function createAndSetupBranch($global, renderer, parentScope, parentNode) {
434
- return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
435
- }
436
- function setupBranch(renderer, branch) {
437
- return renderer.c && queueRender(branch, renderer.c, -1), branch;
438
- }
439
- function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
440
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
441
- let clone = template ? (branch, ns) => {
442
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
443
- } : (branch) => {
444
- walk(branch.S = branch.K = new Text(), walks, branch);
445
- };
446
- return (owner) => ({
447
- a: id,
448
- b: clone,
449
- e: owner,
450
- c: setup,
451
- d: params,
452
- f: dynamicScopesAccessor
453
- });
454
- }
455
- function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
456
- return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
457
- }
458
- function _content_closures(renderer, closureFns) {
459
- let closureSignals = {};
460
- for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
461
- return (owner, closureValues) => {
462
- let instance = renderer(owner);
463
- return instance.g = closureSignals, instance.h = closureValues, instance;
464
- };
465
- }
466
- function createCloneableHTML(html, ns) {
467
- let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
468
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
469
- walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
470
- } : (branch, walks) => {
471
- let clone = parent.cloneNode(!0);
472
- walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
473
- };
474
- }
475
- //#endregion
476
412
  //#region src/dom/resume.ts
477
413
  function enableBranches() {
478
414
  branchesEnabled || (branchesEnabled = 1, skipDestroyedRenders());
@@ -587,6 +523,210 @@ function _el(id, accessor) {
587
523
  return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
588
524
  }
589
525
  //#endregion
526
+ //#region src/dom/renderer.ts
527
+ function createBranch($global, renderer, parentScope, parentNode) {
528
+ let branch = createScope($global);
529
+ return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
530
+ }
531
+ function setParentBranch(branch, parentBranch) {
532
+ parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
533
+ }
534
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
535
+ return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
536
+ }
537
+ function setupBranch(renderer, branch) {
538
+ return renderer.c && queueRender(branch, renderer.c, -1), branch;
539
+ }
540
+ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
541
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
542
+ let clone = template ? (branch, ns) => {
543
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
544
+ } : (branch) => {
545
+ walk(branch.S = branch.K = new Text(), walks, branch);
546
+ };
547
+ return (owner) => ({
548
+ a: id,
549
+ b: clone,
550
+ e: owner,
551
+ c: setup,
552
+ d: params,
553
+ f: dynamicScopesAccessor
554
+ });
555
+ }
556
+ function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
557
+ return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
558
+ }
559
+ function _content_closures(renderer, closureFns) {
560
+ let closureSignals = {};
561
+ for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
562
+ return (owner, closureValues) => {
563
+ let instance = renderer(owner);
564
+ return instance.g = closureSignals, instance.h = closureValues, instance;
565
+ };
566
+ }
567
+ function createCloneableHTML(html, ns) {
568
+ let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
569
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
570
+ walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
571
+ } : (branch, walks) => {
572
+ let clone = parent.cloneNode(!0);
573
+ walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
574
+ };
575
+ }
576
+ //#endregion
577
+ //#region src/dom/dom.ts
578
+ function _to_text(value) {
579
+ return value || value === 0 ? value + "" : "";
580
+ }
581
+ function _attr(element, name, value) {
582
+ setAttribute(element, name, normalizeAttrValue(value));
583
+ }
584
+ function setAttribute(element, name, value) {
585
+ element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
586
+ }
587
+ function _attr_class(element, value) {
588
+ setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
589
+ }
590
+ function _attr_class_items(element, items) {
591
+ for (let key in items) _attr_class_item(element, key, items[key]);
592
+ }
593
+ function _attr_class_item(element, name, value) {
594
+ element.classList.toggle(name, !!value);
595
+ }
596
+ function _attr_style(element, value) {
597
+ setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
598
+ }
599
+ function _attr_style_items(element, items) {
600
+ for (let key in items) _attr_style_item(element, key, items[key]);
601
+ }
602
+ function _attr_style_item(element, name, value) {
603
+ element.style.setProperty(name, _to_text(value));
604
+ }
605
+ function _style_shell(scope, nodeAccessor) {
606
+ let element = scope[nodeAccessor], id = _id(scope);
607
+ _attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
608
+ }
609
+ function _style_rule_item(element, name, value) {
610
+ let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
611
+ ~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
612
+ }
613
+ function _attr_nonce(scope, nodeAccessor) {
614
+ _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
615
+ }
616
+ function _text(node, value) {
617
+ let normalizedValue = _to_text(value);
618
+ node.data !== normalizedValue && (node.data = normalizedValue);
619
+ }
620
+ function _text_content(node, value) {
621
+ let normalizedValue = _to_text(value);
622
+ node.textContent !== normalizedValue && (node.textContent = normalizedValue);
623
+ }
624
+ function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
625
+ let el = scope[nodeAccessor];
626
+ for (let i = el.attributes.length; i--;) {
627
+ let { name } = el.attributes.item(i);
628
+ nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
629
+ }
630
+ attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
631
+ }
632
+ function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
633
+ _attrs(scope, nodeAccessor, nextAttrs, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
634
+ }
635
+ function hasAttrAlias(element, attr, nextAttrs) {
636
+ return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
637
+ }
638
+ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
639
+ let el = scope[nodeAccessor], partial = {};
640
+ for (let i = el.attributes.length; i--;) {
641
+ let { name } = el.attributes.item(i);
642
+ !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
643
+ }
644
+ for (let name in nextAttrs) {
645
+ let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
646
+ skip[key] || (partial[key] = nextAttrs[name]);
647
+ }
648
+ attrsInternal(scope, nodeAccessor, partial, controllable);
649
+ }
650
+ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
651
+ _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
652
+ }
653
+ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
654
+ let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
655
+ for (let name in events) events[name] = 0;
656
+ controllable && (scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0, nextAttrs && (skip = controllable(scope, nodeAccessor, nextAttrs)));
657
+ for (let name in nextAttrs) {
658
+ let value = nextAttrs[name];
659
+ switch (name) {
660
+ case "class":
661
+ _attr_class(el, value);
662
+ break;
663
+ case "style":
664
+ _attr_style(el, value);
665
+ break;
666
+ default:
667
+ isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
668
+ break;
669
+ }
670
+ }
671
+ }
672
+ function _attr_content(scope, nodeAccessor, value) {
673
+ let content = normalizeClientRender(value);
674
+ scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
675
+ for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
676
+ }
677
+ function _attrs_script(scope, nodeAccessor) {
678
+ let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
679
+ controllableScripts[scope["F" + nodeAccessor]]?.(scope, nodeAccessor);
680
+ for (let name in events) _on(el, name, events[name]);
681
+ }
682
+ function _html(scope, value, accessor) {
683
+ let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
684
+ insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
685
+ }
686
+ function normalizeClientRender(value) {
687
+ let renderer = normalizeDynamicRenderer(value);
688
+ if (renderer && renderer.a) return renderer;
689
+ }
690
+ function normalizeAttrValue(value) {
691
+ if (isNotVoid(value)) return value === !0 ? "" : value + "";
692
+ }
693
+ function _lifecycle(scope, thisObj, index = 0) {
694
+ let accessor = "K" + index, instance = scope[accessor];
695
+ instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
696
+ }
697
+ function removeChildNodes(startNode, endNode) {
698
+ let stop = endNode.nextSibling;
699
+ for (; startNode !== stop;) {
700
+ let next = startNode.nextSibling;
701
+ startNode.remove(), startNode = next;
702
+ }
703
+ }
704
+ function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
705
+ parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
706
+ }
707
+ function toInsertNode(startNode, endNode) {
708
+ if (startNode === endNode) return startNode;
709
+ let parent = new DocumentFragment(), stop = endNode.nextSibling;
710
+ for (; startNode !== stop;) {
711
+ let next = startNode.nextSibling;
712
+ parent.appendChild(startNode), startNode = next;
713
+ }
714
+ return parent;
715
+ }
716
+ //#endregion
717
+ //#region src/dom/resolve-cursor-position.ts
718
+ function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
719
+ if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
720
+ let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
721
+ if (updatedValue.startsWith(before)) return initialPosition;
722
+ if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
723
+ let count = before.replace(R, "").length, pos = 0;
724
+ for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
725
+ return pos;
726
+ }
727
+ return -1;
728
+ }
729
+ //#endregion
590
730
  //#region src/dom/controllable.ts
591
731
  function _attr_input_checked_default(scope, nodeAccessor, checked) {
592
732
  let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
@@ -795,147 +935,6 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
795
935
  if ("open" in nextAttrs || "openChange" in nextAttrs) return _attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange), /^open(?:Change)?$/;
796
936
  }
797
937
  //#endregion
798
- //#region src/dom/dom.ts
799
- function _to_text(value) {
800
- return value || value === 0 ? value + "" : "";
801
- }
802
- function _attr(element, name, value) {
803
- setAttribute(element, name, normalizeAttrValue(value));
804
- }
805
- function setAttribute(element, name, value) {
806
- element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
807
- }
808
- function _attr_class(element, value) {
809
- setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
810
- }
811
- function _attr_class_items(element, items) {
812
- for (let key in items) _attr_class_item(element, key, items[key]);
813
- }
814
- function _attr_class_item(element, name, value) {
815
- element.classList.toggle(name, !!value);
816
- }
817
- function _attr_style(element, value) {
818
- setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
819
- }
820
- function _attr_style_items(element, items) {
821
- for (let key in items) _attr_style_item(element, key, items[key]);
822
- }
823
- function _attr_style_item(element, name, value) {
824
- element.style.setProperty(name, _to_text(value));
825
- }
826
- function _style_shell(scope, nodeAccessor) {
827
- let element = scope[nodeAccessor], id = _id(scope);
828
- _attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
829
- }
830
- function _style_rule_item(element, name, value) {
831
- let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
832
- ~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
833
- }
834
- function _attr_nonce(scope, nodeAccessor) {
835
- _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
836
- }
837
- function _text(node, value) {
838
- let normalizedValue = _to_text(value);
839
- node.data !== normalizedValue && (node.data = normalizedValue);
840
- }
841
- function _text_content(node, value) {
842
- let normalizedValue = _to_text(value);
843
- node.textContent !== normalizedValue && (node.textContent = normalizedValue);
844
- }
845
- function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
846
- let el = scope[nodeAccessor];
847
- for (let i = el.attributes.length; i--;) {
848
- let { name } = el.attributes.item(i);
849
- nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
850
- }
851
- attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
852
- }
853
- function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
854
- _attrs(scope, nodeAccessor, nextAttrs, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
855
- }
856
- function hasAttrAlias(element, attr, nextAttrs) {
857
- return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
858
- }
859
- function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
860
- let el = scope[nodeAccessor], partial = {};
861
- for (let i = el.attributes.length; i--;) {
862
- let { name } = el.attributes.item(i);
863
- !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
864
- }
865
- for (let name in nextAttrs) {
866
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
867
- skip[key] || (partial[key] = nextAttrs[name]);
868
- }
869
- attrsInternal(scope, nodeAccessor, partial, controllable);
870
- }
871
- function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
872
- _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable), _attr_content(scope, nodeAccessor, nextAttrs?.content);
873
- }
874
- function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
875
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
876
- for (let name in events) events[name] = 0;
877
- scope["F" + nodeAccessor] = 5, scope["E" + nodeAccessor] = 0;
878
- let skip = nextAttrs && (controllable || controllableRenders[el.tagName])?.(scope, nodeAccessor, nextAttrs);
879
- for (let name in nextAttrs) {
880
- let value = nextAttrs[name];
881
- switch (name) {
882
- case "class":
883
- _attr_class(el, value);
884
- break;
885
- case "style":
886
- _attr_style(el, value);
887
- break;
888
- default:
889
- isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
890
- break;
891
- }
892
- }
893
- }
894
- function _attr_content(scope, nodeAccessor, value) {
895
- let content = normalizeClientRender(value);
896
- scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
897
- for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
898
- }
899
- function _attrs_script(scope, nodeAccessor) {
900
- let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
901
- controllableScripts[scope["F" + nodeAccessor]]?.(scope, nodeAccessor);
902
- for (let name in events) _on(el, name, events[name]);
903
- }
904
- function _html(scope, value, accessor) {
905
- let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
906
- insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
907
- }
908
- function normalizeClientRender(value) {
909
- let renderer = normalizeDynamicRenderer(value);
910
- if (renderer && renderer.a) return renderer;
911
- }
912
- function normalizeAttrValue(value) {
913
- if (isNotVoid(value)) return value === !0 ? "" : value + "";
914
- }
915
- function _lifecycle(scope, thisObj, index = 0) {
916
- let accessor = "K" + index, instance = scope[accessor];
917
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, Object.assign(thisObj, thisObj.onMount?.()), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
918
- }
919
- function removeChildNodes(startNode, endNode) {
920
- let stop = endNode.nextSibling;
921
- for (; startNode !== stop;) {
922
- let next = startNode.nextSibling;
923
- startNode.remove(), startNode = next;
924
- }
925
- }
926
- function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
927
- parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
928
- }
929
- function toInsertNode(startNode, endNode) {
930
- if (startNode === endNode) return startNode;
931
- let parent = new DocumentFragment(), stop = endNode.nextSibling;
932
- for (; startNode !== stop;) {
933
- let next = startNode.nextSibling;
934
- parent.appendChild(startNode), startNode = next;
935
- }
936
- return parent;
937
- }
938
- //#endregion
939
938
  //#region src/dom/control-flow.ts
940
939
  function _await_promise(nodeAccessor, params) {
941
940
  nodeAccessor = decodeAccessor(nodeAccessor);
@@ -1240,7 +1239,7 @@ function _enable_catch() {
1240
1239
  //#region src/dom/abort-signal.ts
1241
1240
  function $signalReset(scope, id) {
1242
1241
  let ctrl = scope.A?.[id];
1243
- ctrl && (queueEffect(ctrl, abort), scope.A[id] = void 0);
1242
+ ctrl && (scope.A[id] = void 0, rendering ? queueEffect(ctrl, abort) : abort(ctrl));
1244
1243
  }
1245
1244
  function $signal(scope, id) {
1246
1245
  return scope.F && (scope.F.B ||= /* @__PURE__ */ new Set()).add(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
@@ -1286,10 +1285,10 @@ function mount(input = {}, reference, position) {
1286
1285
  set value(newValue) {
1287
1286
  _var_change(branch, newValue);
1288
1287
  },
1289
- update(newInput) {
1290
- args && runEffects(prepareEffects(() => {
1288
+ update(newInput = {}) {
1289
+ args && (newInput.$global && ({$global, ...newInput} = newInput), runEffects(prepareEffects(() => {
1291
1290
  args(branch, newInput);
1292
- }));
1291
+ })));
1293
1292
  },
1294
1293
  destroy() {
1295
1294
  removeAndDestroyBranch(branch);