marko 6.3.24 → 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.
- package/dist/common/constants/accessor-prefix.d.ts +1 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
- package/dist/common/constants/walk-range-size.d.ts +1 -1
- package/dist/debug/dom.js +375 -339
- package/dist/debug/dom.mjs +367 -340
- package/dist/debug/html.js +9 -3
- package/dist/debug/html.mjs +9 -3
- package/dist/dom/controllable.d.ts +22 -1
- package/dist/dom/dom.d.ts +5 -4
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +258 -249
- package/dist/dom.mjs +257 -248
- package/dist/html.js +8 -3
- package/dist/html.mjs +8 -3
- package/dist/translator/index.js +158 -36
- package/dist/translator/util/translate-attrs.d.ts +2 -0
- package/dist/translator/util/walks.d.ts +3 -0
- package/dist/translator/visitors/tag/native-tag.d.ts +10 -0
- package/package.json +4 -4
package/dist/debug/dom.mjs
CHANGED
|
@@ -24,6 +24,7 @@ const BranchScopes$1 = "BranchScopes:";
|
|
|
24
24
|
const ClosureScopes = "ClosureScopes:";
|
|
25
25
|
const ClosureSignalIndex = "ClosureSignalIndex:";
|
|
26
26
|
const ConditionalRenderer = "ConditionalRenderer:";
|
|
27
|
+
const ControlledObserver = "ControlledObserver:";
|
|
27
28
|
const ControlledHandler = "ControlledHandler:";
|
|
28
29
|
const ControlledType = "ControlledType:";
|
|
29
30
|
const ControlledValue = "ControlledValue:";
|
|
@@ -344,22 +345,6 @@ function handleDelegated(ev) {
|
|
|
344
345
|
delete ev.currentTarget;
|
|
345
346
|
}
|
|
346
347
|
//#endregion
|
|
347
|
-
//#region src/dom/resolve-cursor-position.ts
|
|
348
|
-
const R = /[^\p{L}\p{N}]/gu;
|
|
349
|
-
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
350
|
-
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
351
|
-
const before = initialValue.slice(0, initialPosition);
|
|
352
|
-
const after = initialValue.slice(initialPosition);
|
|
353
|
-
if (updatedValue.startsWith(before)) return initialPosition;
|
|
354
|
-
if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
|
|
355
|
-
let count = before.replace(R, "").length;
|
|
356
|
-
let pos = 0;
|
|
357
|
-
while (count && updatedValue[pos]) if (updatedValue[pos++].replace(R, "")) count--;
|
|
358
|
-
return pos;
|
|
359
|
-
}
|
|
360
|
-
return -1;
|
|
361
|
-
}
|
|
362
|
-
//#endregion
|
|
363
348
|
//#region src/dom/parse-html.ts
|
|
364
349
|
const parsers = {};
|
|
365
350
|
function parseHTML(html, ns) {
|
|
@@ -685,7 +670,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
685
670
|
currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[getDebugKey(currentScopeIndex++, "#childScope")] = createScope(scope[Global], scope[ClosestBranch]));
|
|
686
671
|
if (value === 48) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
|
|
687
672
|
} else if (value < 92) {
|
|
688
|
-
value =
|
|
673
|
+
value = 25 * currentMultiplier + value - 67;
|
|
689
674
|
while (value--) walker.nextNode();
|
|
690
675
|
} else if (value < 107) {
|
|
691
676
|
value = 10 * currentMultiplier + value - 97;
|
|
@@ -708,77 +693,6 @@ function getDebugKey(index, node) {
|
|
|
708
693
|
return index;
|
|
709
694
|
}
|
|
710
695
|
//#endregion
|
|
711
|
-
//#region src/dom/renderer.ts
|
|
712
|
-
function createBranch($global, renderer, parentScope, parentNode) {
|
|
713
|
-
const branch = createScope($global);
|
|
714
|
-
branch["_"] = renderer["owner"] || parentScope;
|
|
715
|
-
setParentBranch(branch, parentScope?.[ClosestBranch]);
|
|
716
|
-
branch[Renderer] = renderer;
|
|
717
|
-
renderer[Clone]?.(branch, parentNode.namespaceURI);
|
|
718
|
-
return branch;
|
|
719
|
-
}
|
|
720
|
-
function setParentBranch(branch, parentBranch) {
|
|
721
|
-
if (parentBranch) {
|
|
722
|
-
branch[ParentBranch] = parentBranch;
|
|
723
|
-
(parentBranch[BranchScopes] ||= /* @__PURE__ */ new Set()).add(branch);
|
|
724
|
-
}
|
|
725
|
-
branch[ClosestBranch] = branch;
|
|
726
|
-
}
|
|
727
|
-
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
728
|
-
return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
|
|
729
|
-
}
|
|
730
|
-
function setupBranch(renderer, branch) {
|
|
731
|
-
if (renderer["setup"]) queueRender(branch, renderer[Setup], -1);
|
|
732
|
-
return branch;
|
|
733
|
-
}
|
|
734
|
-
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
735
|
-
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
736
|
-
setup = setup ? setup._ || setup : void 0;
|
|
737
|
-
params ||= void 0;
|
|
738
|
-
const clone = template ? (branch, ns) => {
|
|
739
|
-
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
|
|
740
|
-
} : (branch) => {
|
|
741
|
-
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
742
|
-
};
|
|
743
|
-
return (owner) => {
|
|
744
|
-
return {
|
|
745
|
-
["id"]: id,
|
|
746
|
-
[Clone]: clone,
|
|
747
|
-
[Owner]: owner,
|
|
748
|
-
[Setup]: setup,
|
|
749
|
-
[Params]: params,
|
|
750
|
-
[Accessor]: dynamicScopesAccessor
|
|
751
|
-
};
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
755
|
-
return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
|
|
756
|
-
}
|
|
757
|
-
function _content_closures(renderer, closureFns) {
|
|
758
|
-
const closureSignals = {};
|
|
759
|
-
for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
|
|
760
|
-
return (owner, closureValues) => {
|
|
761
|
-
const instance = renderer(owner);
|
|
762
|
-
instance[LocalClosures] = closureSignals;
|
|
763
|
-
instance[LocalClosureValues] = closureValues;
|
|
764
|
-
return instance;
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
const cloneCache = {};
|
|
768
|
-
function createCloneableHTML(html, ns) {
|
|
769
|
-
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
770
|
-
const parent = document.createElementNS(ns, "t");
|
|
771
|
-
insertChildNodes(parent, null, firstChild, lastChild);
|
|
772
|
-
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
773
|
-
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
774
|
-
} : (branch, walks) => {
|
|
775
|
-
const clone = parent.cloneNode(true);
|
|
776
|
-
walk(clone.firstChild, walks, branch);
|
|
777
|
-
branch[StartNode] = clone.firstChild;
|
|
778
|
-
branch[EndNode] = clone.lastChild;
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
//#endregion
|
|
782
696
|
//#region src/dom/resume.ts
|
|
783
697
|
const registeredValues = {};
|
|
784
698
|
let curRenders;
|
|
@@ -983,19 +897,295 @@ function runResumeEffects(render) {
|
|
|
983
897
|
isResuming = 0;
|
|
984
898
|
}
|
|
985
899
|
}
|
|
986
|
-
function getRegisteredWithScope(id, scope) {
|
|
987
|
-
const val = registeredValues[id];
|
|
988
|
-
return scope ? val(scope) : val;
|
|
900
|
+
function getRegisteredWithScope(id, scope) {
|
|
901
|
+
const val = registeredValues[id];
|
|
902
|
+
return scope ? val(scope) : val;
|
|
903
|
+
}
|
|
904
|
+
function _resume(id, obj) {
|
|
905
|
+
return registeredValues[id] = obj;
|
|
906
|
+
}
|
|
907
|
+
function _var_resume(id, signal) {
|
|
908
|
+
_resume(id, (scope) => (value) => signal(scope, value));
|
|
909
|
+
return signal;
|
|
910
|
+
}
|
|
911
|
+
function _el(id, accessor) {
|
|
912
|
+
return _resume(id, (scope) => () => _el_read(scope[accessor]));
|
|
913
|
+
}
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/dom/renderer.ts
|
|
916
|
+
function createBranch($global, renderer, parentScope, parentNode) {
|
|
917
|
+
const branch = createScope($global);
|
|
918
|
+
branch["_"] = renderer["owner"] || parentScope;
|
|
919
|
+
setParentBranch(branch, parentScope?.[ClosestBranch]);
|
|
920
|
+
branch[Renderer] = renderer;
|
|
921
|
+
renderer[Clone]?.(branch, parentNode.namespaceURI);
|
|
922
|
+
return branch;
|
|
923
|
+
}
|
|
924
|
+
function setParentBranch(branch, parentBranch) {
|
|
925
|
+
if (parentBranch) {
|
|
926
|
+
branch[ParentBranch] = parentBranch;
|
|
927
|
+
(parentBranch[BranchScopes] ||= /* @__PURE__ */ new Set()).add(branch);
|
|
928
|
+
}
|
|
929
|
+
branch[ClosestBranch] = branch;
|
|
930
|
+
}
|
|
931
|
+
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
932
|
+
return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
|
|
933
|
+
}
|
|
934
|
+
function setupBranch(renderer, branch) {
|
|
935
|
+
if (renderer["setup"]) queueRender(branch, renderer[Setup], -1);
|
|
936
|
+
return branch;
|
|
937
|
+
}
|
|
938
|
+
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
939
|
+
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
940
|
+
setup = setup ? setup._ || setup : void 0;
|
|
941
|
+
params ||= void 0;
|
|
942
|
+
const clone = template ? (branch, ns) => {
|
|
943
|
+
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
|
|
944
|
+
} : (branch) => {
|
|
945
|
+
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
946
|
+
};
|
|
947
|
+
return (owner) => {
|
|
948
|
+
return {
|
|
949
|
+
["id"]: id,
|
|
950
|
+
[Clone]: clone,
|
|
951
|
+
[Owner]: owner,
|
|
952
|
+
[Setup]: setup,
|
|
953
|
+
[Params]: params,
|
|
954
|
+
[Accessor]: dynamicScopesAccessor
|
|
955
|
+
};
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
959
|
+
return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
|
|
960
|
+
}
|
|
961
|
+
function _content_closures(renderer, closureFns) {
|
|
962
|
+
const closureSignals = {};
|
|
963
|
+
for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
|
|
964
|
+
return (owner, closureValues) => {
|
|
965
|
+
const instance = renderer(owner);
|
|
966
|
+
instance[LocalClosures] = closureSignals;
|
|
967
|
+
instance[LocalClosureValues] = closureValues;
|
|
968
|
+
return instance;
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
const cloneCache = {};
|
|
972
|
+
function createCloneableHTML(html, ns) {
|
|
973
|
+
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
974
|
+
const parent = document.createElementNS(ns, "t");
|
|
975
|
+
insertChildNodes(parent, null, firstChild, lastChild);
|
|
976
|
+
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
977
|
+
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
978
|
+
} : (branch, walks) => {
|
|
979
|
+
const clone = parent.cloneNode(true);
|
|
980
|
+
walk(clone.firstChild, walks, branch);
|
|
981
|
+
branch[StartNode] = clone.firstChild;
|
|
982
|
+
branch[EndNode] = clone.lastChild;
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/dom/dom.ts
|
|
987
|
+
function _to_text(value) {
|
|
988
|
+
assertValidTextValue(value);
|
|
989
|
+
return value || value === 0 ? value + "" : "";
|
|
990
|
+
}
|
|
991
|
+
function _attr(element, name, value) {
|
|
992
|
+
assertValidAttrValue(name, value);
|
|
993
|
+
setAttribute(element, name, normalizeAttrValue(value));
|
|
994
|
+
}
|
|
995
|
+
function setAttribute(element, name, value) {
|
|
996
|
+
if (element.getAttribute(name) != value) if (value === void 0) element.removeAttribute(name);
|
|
997
|
+
else element.setAttribute(name, value);
|
|
998
|
+
}
|
|
999
|
+
function _attr_class(element, value) {
|
|
1000
|
+
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
1001
|
+
}
|
|
1002
|
+
function _attr_class_items(element, items) {
|
|
1003
|
+
for (const key in items) _attr_class_item(element, key, items[key]);
|
|
1004
|
+
}
|
|
1005
|
+
function _attr_class_item(element, name, value) {
|
|
1006
|
+
element.classList.toggle(name, !!value);
|
|
1007
|
+
}
|
|
1008
|
+
function _attr_style(element, value) {
|
|
1009
|
+
setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
|
|
1010
|
+
}
|
|
1011
|
+
function _attr_style_items(element, items) {
|
|
1012
|
+
for (const key in items) _attr_style_item(element, key, items[key]);
|
|
1013
|
+
}
|
|
1014
|
+
function _attr_style_item(element, name, value) {
|
|
1015
|
+
element.style.setProperty(name, _to_text(value));
|
|
1016
|
+
}
|
|
1017
|
+
function _style_shell(scope, nodeAccessor) {
|
|
1018
|
+
const element = scope[nodeAccessor];
|
|
1019
|
+
const id = _id(scope);
|
|
1020
|
+
_attr_nonce(scope, nodeAccessor);
|
|
1021
|
+
element.className = id;
|
|
1022
|
+
_text_content(element, "." + id + "~*{}");
|
|
1023
|
+
}
|
|
1024
|
+
function _style_rule_item(element, name, value) {
|
|
1025
|
+
const text = element.textContent;
|
|
1026
|
+
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1027
|
+
let start = text.indexOf("{" + name + ":");
|
|
1028
|
+
if (!~start) start = text.indexOf(";" + name + ":");
|
|
1029
|
+
_text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
1030
|
+
}
|
|
1031
|
+
function _attr_nonce(scope, nodeAccessor) {
|
|
1032
|
+
_attr(scope[nodeAccessor], "nonce", scope[Global].cspNonce);
|
|
1033
|
+
}
|
|
1034
|
+
function _text(node, value) {
|
|
1035
|
+
const normalizedValue = _to_text(value);
|
|
1036
|
+
if (node.data !== normalizedValue) node.data = normalizedValue;
|
|
1037
|
+
}
|
|
1038
|
+
function _text_content(node, value) {
|
|
1039
|
+
const normalizedValue = _to_text(value);
|
|
1040
|
+
if (node.textContent !== normalizedValue) node.textContent = normalizedValue;
|
|
1041
|
+
}
|
|
1042
|
+
function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1043
|
+
const el = scope[nodeAccessor];
|
|
1044
|
+
for (let i = el.attributes.length; i--;) {
|
|
1045
|
+
const { name } = el.attributes.item(i);
|
|
1046
|
+
if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) el.removeAttribute(name);
|
|
1047
|
+
}
|
|
1048
|
+
assertExclusiveAttrs(nextAttrs);
|
|
1049
|
+
attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
|
|
1050
|
+
}
|
|
1051
|
+
function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1052
|
+
_attrs(scope, nodeAccessor, nextAttrs, controllable);
|
|
1053
|
+
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1054
|
+
}
|
|
1055
|
+
function hasAttrAlias(element, attr, nextAttrs) {
|
|
1056
|
+
return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
|
|
1057
|
+
}
|
|
1058
|
+
function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
|
|
1059
|
+
const el = scope[nodeAccessor];
|
|
1060
|
+
const partial = {};
|
|
1061
|
+
for (let i = el.attributes.length; i--;) {
|
|
1062
|
+
const { name } = el.attributes.item(i);
|
|
1063
|
+
if (!skip[name] && !(nextAttrs && name in nextAttrs)) el.removeAttribute(name);
|
|
1064
|
+
}
|
|
1065
|
+
for (const name in nextAttrs) {
|
|
1066
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1067
|
+
if (!skip[key]) partial[key] = nextAttrs[name];
|
|
1068
|
+
}
|
|
1069
|
+
assertExclusiveAttrs({
|
|
1070
|
+
...nextAttrs,
|
|
1071
|
+
...skip
|
|
1072
|
+
});
|
|
1073
|
+
attrsInternal(scope, nodeAccessor, partial, controllable);
|
|
1074
|
+
}
|
|
1075
|
+
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
|
|
1076
|
+
_attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable);
|
|
1077
|
+
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1078
|
+
}
|
|
1079
|
+
function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1080
|
+
const el = scope[nodeAccessor];
|
|
1081
|
+
let events = scope[EventAttributes + nodeAccessor];
|
|
1082
|
+
let skip = void 0;
|
|
1083
|
+
for (const name in events) events[name] = 0;
|
|
1084
|
+
if (controllable) {
|
|
1085
|
+
scope[ControlledType + nodeAccessor] = 5;
|
|
1086
|
+
scope[ControlledHandler + nodeAccessor] = 0;
|
|
1087
|
+
if (nextAttrs) skip = controllable(scope, nodeAccessor, nextAttrs);
|
|
1088
|
+
}
|
|
1089
|
+
for (const name in nextAttrs) {
|
|
1090
|
+
const value = nextAttrs[name];
|
|
1091
|
+
switch (name) {
|
|
1092
|
+
case "class":
|
|
1093
|
+
_attr_class(el, value);
|
|
1094
|
+
break;
|
|
1095
|
+
case "style":
|
|
1096
|
+
_attr_style(el, value);
|
|
1097
|
+
break;
|
|
1098
|
+
default:
|
|
1099
|
+
assertValidAttrName(name);
|
|
1100
|
+
if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1101
|
+
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function _attr_content(scope, nodeAccessor, value) {
|
|
1107
|
+
const content = normalizeClientRender(value);
|
|
1108
|
+
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
|
|
1109
|
+
setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1110
|
+
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
1111
|
+
}
|
|
1112
|
+
for (const accessor in content?.[LocalClosures]) content[LocalClosures][accessor](scope[BranchScopes$1 + nodeAccessor], content[LocalClosureValues][accessor]);
|
|
1113
|
+
}
|
|
1114
|
+
function _attrs_script(scope, nodeAccessor) {
|
|
1115
|
+
const el = scope[nodeAccessor];
|
|
1116
|
+
const events = scope[EventAttributes + nodeAccessor];
|
|
1117
|
+
controllableScripts[scope[ControlledType + nodeAccessor]]?.(scope, nodeAccessor);
|
|
1118
|
+
for (const name in events) _on(el, name, events[name]);
|
|
1119
|
+
}
|
|
1120
|
+
function _html(scope, value, accessor) {
|
|
1121
|
+
const firstChild = scope[accessor];
|
|
1122
|
+
const parentNode = firstChild.parentNode;
|
|
1123
|
+
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1124
|
+
const newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
|
|
1125
|
+
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope[DynamicHTMLLastChild + accessor] = newContent.lastChild);
|
|
1126
|
+
removeChildNodes(firstChild, lastChild);
|
|
1127
|
+
}
|
|
1128
|
+
function normalizeClientRender(value) {
|
|
1129
|
+
const renderer = normalizeDynamicRenderer(value);
|
|
1130
|
+
if (renderer) if (renderer["id"]) return renderer;
|
|
1131
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1132
|
+
}
|
|
1133
|
+
function normalizeAttrValue(value) {
|
|
1134
|
+
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
1135
|
+
}
|
|
1136
|
+
function _lifecycle(scope, thisObj, index = 0) {
|
|
1137
|
+
const accessor = Lifecycle + index;
|
|
1138
|
+
const instance = scope[accessor];
|
|
1139
|
+
if (instance) {
|
|
1140
|
+
Object.assign(instance, thisObj);
|
|
1141
|
+
instance.onUpdate?.();
|
|
1142
|
+
} else {
|
|
1143
|
+
scope[accessor] = thisObj;
|
|
1144
|
+
{
|
|
1145
|
+
const snapshot = { ...thisObj };
|
|
1146
|
+
Object.assign(thisObj, thisObj.onMount?.());
|
|
1147
|
+
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1148
|
+
}
|
|
1149
|
+
$signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
function removeChildNodes(startNode, endNode) {
|
|
1153
|
+
const stop = endNode.nextSibling;
|
|
1154
|
+
while (startNode !== stop) {
|
|
1155
|
+
const next = startNode.nextSibling;
|
|
1156
|
+
startNode.remove();
|
|
1157
|
+
startNode = next;
|
|
1158
|
+
}
|
|
989
1159
|
}
|
|
990
|
-
function
|
|
991
|
-
|
|
1160
|
+
function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
|
1161
|
+
parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
|
|
992
1162
|
}
|
|
993
|
-
function
|
|
994
|
-
|
|
995
|
-
|
|
1163
|
+
function toInsertNode(startNode, endNode) {
|
|
1164
|
+
if (startNode === endNode) return startNode;
|
|
1165
|
+
const parent = new DocumentFragment();
|
|
1166
|
+
const stop = endNode.nextSibling;
|
|
1167
|
+
while (startNode !== stop) {
|
|
1168
|
+
const next = startNode.nextSibling;
|
|
1169
|
+
parent.appendChild(startNode);
|
|
1170
|
+
startNode = next;
|
|
1171
|
+
}
|
|
1172
|
+
return parent;
|
|
996
1173
|
}
|
|
997
|
-
|
|
998
|
-
|
|
1174
|
+
//#endregion
|
|
1175
|
+
//#region src/dom/resolve-cursor-position.ts
|
|
1176
|
+
const R = /[^\p{L}\p{N}]/gu;
|
|
1177
|
+
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
1178
|
+
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
1179
|
+
const before = initialValue.slice(0, initialPosition);
|
|
1180
|
+
const after = initialValue.slice(initialPosition);
|
|
1181
|
+
if (updatedValue.startsWith(before)) return initialPosition;
|
|
1182
|
+
if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
|
|
1183
|
+
let count = before.replace(R, "").length;
|
|
1184
|
+
let pos = 0;
|
|
1185
|
+
while (count && updatedValue[pos]) if (updatedValue[pos++].replace(R, "")) count--;
|
|
1186
|
+
return pos;
|
|
1187
|
+
}
|
|
1188
|
+
return -1;
|
|
999
1189
|
}
|
|
1000
1190
|
//#endregion
|
|
1001
1191
|
//#region src/dom/controllable.ts
|
|
@@ -1009,6 +1199,36 @@ function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
|
1009
1199
|
if (restoreValue !== normalizedChecked) el.checked = restoreValue;
|
|
1010
1200
|
}
|
|
1011
1201
|
}
|
|
1202
|
+
/** Filled by the latches a compiled page emits, so a page carries only the
|
|
1203
|
+
* control kinds its tags can be (`_attrs_script` resolves the kind at run time). */
|
|
1204
|
+
const controllableScripts = {};
|
|
1205
|
+
/** The render pass equivalent, for a tag whose name is only known at run time;
|
|
1206
|
+
* a statically named tag passes its claim to `_attrs` instead. */
|
|
1207
|
+
const controllableRenders = {};
|
|
1208
|
+
function _enable_controllable_input() {
|
|
1209
|
+
controllableScripts[0] = _attr_input_checked_script;
|
|
1210
|
+
controllableScripts[1] = _attr_input_checkedValue_script;
|
|
1211
|
+
controllableScripts[2] = _attr_input_value_script;
|
|
1212
|
+
}
|
|
1213
|
+
function _enable_controllable_textarea() {
|
|
1214
|
+
controllableScripts[2] = _attr_input_value_script;
|
|
1215
|
+
}
|
|
1216
|
+
function _enable_controllable_select() {
|
|
1217
|
+
controllableScripts[3] = _attr_select_value_script;
|
|
1218
|
+
}
|
|
1219
|
+
function _enable_controllable_open() {
|
|
1220
|
+
controllableScripts[4] = _attr_details_or_dialog_open_script;
|
|
1221
|
+
}
|
|
1222
|
+
/** A run-time tag name can be any controllable, so its page enables them all. */
|
|
1223
|
+
function _enable_controllable() {
|
|
1224
|
+
_enable_controllable_input();
|
|
1225
|
+
_enable_controllable_select();
|
|
1226
|
+
_enable_controllable_open();
|
|
1227
|
+
controllableRenders.INPUT = _controllable_input;
|
|
1228
|
+
controllableRenders.TEXTAREA = _controllable_textarea;
|
|
1229
|
+
controllableRenders.SELECT = _controllable_select;
|
|
1230
|
+
controllableRenders.DETAILS = controllableRenders.DIALOG = _controllable_open;
|
|
1231
|
+
}
|
|
1012
1232
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
1013
1233
|
const el = scope[nodeAccessor];
|
|
1014
1234
|
const normalizedChecked = isNotVoid(checked);
|
|
@@ -1170,12 +1390,12 @@ function _attr_select_value_script(scope, nodeAccessor) {
|
|
|
1170
1390
|
}
|
|
1171
1391
|
}
|
|
1172
1392
|
syncControllableFormInput(el, hasSelectChanged, onChange);
|
|
1173
|
-
|
|
1174
|
-
const value = scope[ControlledValue + nodeAccessor];
|
|
1175
|
-
if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
|
|
1176
|
-
}).observe(el, {
|
|
1393
|
+
observeOnce(scope, nodeAccessor, {
|
|
1177
1394
|
childList: true,
|
|
1178
1395
|
subtree: true
|
|
1396
|
+
}, () => {
|
|
1397
|
+
const value = scope[ControlledValue + nodeAccessor];
|
|
1398
|
+
if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
|
|
1179
1399
|
});
|
|
1180
1400
|
}
|
|
1181
1401
|
function setSelectValue(el, value, multiple) {
|
|
@@ -1205,7 +1425,10 @@ function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
|
1205
1425
|
}
|
|
1206
1426
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
1207
1427
|
const el = scope[nodeAccessor];
|
|
1208
|
-
|
|
1428
|
+
observeOnce(scope, nodeAccessor, {
|
|
1429
|
+
attributes: true,
|
|
1430
|
+
attributeFilter: ["open"]
|
|
1431
|
+
}, () => {
|
|
1209
1432
|
const openChange = scope[ControlledHandler + nodeAccessor];
|
|
1210
1433
|
if (openChange && el.open === !scope["ControlledValue:" + nodeAccessor]) {
|
|
1211
1434
|
const newValue = el.open;
|
|
@@ -1213,11 +1436,11 @@ function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
|
1213
1436
|
openChange(newValue);
|
|
1214
1437
|
run();
|
|
1215
1438
|
}
|
|
1216
|
-
}).observe(el, {
|
|
1217
|
-
attributes: true,
|
|
1218
|
-
attributeFilter: ["open"]
|
|
1219
1439
|
});
|
|
1220
1440
|
}
|
|
1441
|
+
function observeOnce(scope, nodeAccessor, init, callback) {
|
|
1442
|
+
(scope[ControlledObserver + nodeAccessor] ||= new MutationObserver(callback)).observe(scope[nodeAccessor], init);
|
|
1443
|
+
}
|
|
1221
1444
|
function syncControllableFormInput(el, hasChanged, onChange) {
|
|
1222
1445
|
el._ = onChange;
|
|
1223
1446
|
delegate("input", handleChange);
|
|
@@ -1253,240 +1476,34 @@ function updateList(arr, val, push) {
|
|
|
1253
1476
|
const index = arr.indexOf(val);
|
|
1254
1477
|
return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
|
|
1255
1478
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
return value || value === 0 ? value + "" : "";
|
|
1261
|
-
}
|
|
1262
|
-
function _attr(element, name, value) {
|
|
1263
|
-
assertValidAttrValue(name, value);
|
|
1264
|
-
setAttribute(element, name, normalizeAttrValue(value));
|
|
1265
|
-
}
|
|
1266
|
-
function setAttribute(element, name, value) {
|
|
1267
|
-
if (element.getAttribute(name) != value) if (value === void 0) element.removeAttribute(name);
|
|
1268
|
-
else element.setAttribute(name, value);
|
|
1269
|
-
}
|
|
1270
|
-
function _attr_class(element, value) {
|
|
1271
|
-
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
1272
|
-
}
|
|
1273
|
-
function _attr_class_items(element, items) {
|
|
1274
|
-
for (const key in items) _attr_class_item(element, key, items[key]);
|
|
1275
|
-
}
|
|
1276
|
-
function _attr_class_item(element, name, value) {
|
|
1277
|
-
element.classList.toggle(name, !!value);
|
|
1278
|
-
}
|
|
1279
|
-
function _attr_style(element, value) {
|
|
1280
|
-
setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
|
|
1281
|
-
}
|
|
1282
|
-
function _attr_style_items(element, items) {
|
|
1283
|
-
for (const key in items) _attr_style_item(element, key, items[key]);
|
|
1284
|
-
}
|
|
1285
|
-
function _attr_style_item(element, name, value) {
|
|
1286
|
-
element.style.setProperty(name, _to_text(value));
|
|
1287
|
-
}
|
|
1288
|
-
function _style_shell(scope, nodeAccessor) {
|
|
1289
|
-
const element = scope[nodeAccessor];
|
|
1290
|
-
const id = _id(scope);
|
|
1291
|
-
_attr_nonce(scope, nodeAccessor);
|
|
1292
|
-
element.className = id;
|
|
1293
|
-
_text_content(element, "." + id + "~*{}");
|
|
1294
|
-
}
|
|
1295
|
-
function _style_rule_item(element, name, value) {
|
|
1296
|
-
const text = element.textContent;
|
|
1297
|
-
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1298
|
-
let start = text.indexOf("{" + name + ":");
|
|
1299
|
-
if (!~start) start = text.indexOf(";" + name + ":");
|
|
1300
|
-
_text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
1301
|
-
}
|
|
1302
|
-
function _attr_nonce(scope, nodeAccessor) {
|
|
1303
|
-
_attr(scope[nodeAccessor], "nonce", scope[Global].cspNonce);
|
|
1304
|
-
}
|
|
1305
|
-
function _text(node, value) {
|
|
1306
|
-
const normalizedValue = _to_text(value);
|
|
1307
|
-
if (node.data !== normalizedValue) node.data = normalizedValue;
|
|
1308
|
-
}
|
|
1309
|
-
function _text_content(node, value) {
|
|
1310
|
-
const normalizedValue = _to_text(value);
|
|
1311
|
-
if (node.textContent !== normalizedValue) node.textContent = normalizedValue;
|
|
1312
|
-
}
|
|
1313
|
-
function _attrs(scope, nodeAccessor, nextAttrs) {
|
|
1314
|
-
const el = scope[nodeAccessor];
|
|
1315
|
-
for (let i = el.attributes.length; i--;) {
|
|
1316
|
-
const { name } = el.attributes.item(i);
|
|
1317
|
-
if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) el.removeAttribute(name);
|
|
1318
|
-
}
|
|
1319
|
-
assertExclusiveAttrs(nextAttrs);
|
|
1320
|
-
attrsInternal(scope, nodeAccessor, nextAttrs);
|
|
1321
|
-
}
|
|
1322
|
-
function _attrs_content(scope, nodeAccessor, nextAttrs) {
|
|
1323
|
-
_attrs(scope, nodeAccessor, nextAttrs);
|
|
1324
|
-
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1325
|
-
}
|
|
1326
|
-
function hasAttrAlias(element, attr, nextAttrs) {
|
|
1327
|
-
return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
|
|
1328
|
-
}
|
|
1329
|
-
function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
|
|
1330
|
-
const el = scope[nodeAccessor];
|
|
1331
|
-
const partial = {};
|
|
1332
|
-
for (let i = el.attributes.length; i--;) {
|
|
1333
|
-
const { name } = el.attributes.item(i);
|
|
1334
|
-
if (!skip[name] && !(nextAttrs && name in nextAttrs)) el.removeAttribute(name);
|
|
1335
|
-
}
|
|
1336
|
-
for (const name in nextAttrs) {
|
|
1337
|
-
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1338
|
-
if (!skip[key]) partial[key] = nextAttrs[name];
|
|
1339
|
-
}
|
|
1340
|
-
assertExclusiveAttrs({
|
|
1341
|
-
...nextAttrs,
|
|
1342
|
-
...skip
|
|
1343
|
-
});
|
|
1344
|
-
attrsInternal(scope, nodeAccessor, partial);
|
|
1345
|
-
}
|
|
1346
|
-
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
1347
|
-
_attrs_partial(scope, nodeAccessor, nextAttrs, skip);
|
|
1348
|
-
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1349
|
-
}
|
|
1350
|
-
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
1351
|
-
const el = scope[nodeAccessor];
|
|
1352
|
-
let events = scope[EventAttributes + nodeAccessor];
|
|
1353
|
-
let skip;
|
|
1354
|
-
for (const name in events) events[name] = 0;
|
|
1355
|
-
scope[ControlledType + nodeAccessor] = 5;
|
|
1356
|
-
scope[ControlledHandler + nodeAccessor] = 0;
|
|
1357
|
-
switch (nextAttrs && el.tagName) {
|
|
1358
|
-
case "INPUT":
|
|
1359
|
-
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
|
|
1360
|
-
_attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
1361
|
-
skip = /^checked(?:Value)?(?:Change)?$/;
|
|
1362
|
-
} else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
|
|
1363
|
-
_attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
|
1364
|
-
skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
|
|
1365
|
-
} else if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1366
|
-
_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, _attr_input_value_dynamic_default);
|
|
1367
|
-
skip = /^value(?:Change)?$/;
|
|
1368
|
-
}
|
|
1369
|
-
break;
|
|
1370
|
-
case "SELECT":
|
|
1371
|
-
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1372
|
-
_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1373
|
-
skip = /^value(?:Change)?$/;
|
|
1374
|
-
}
|
|
1375
|
-
break;
|
|
1376
|
-
case "TEXTAREA":
|
|
1377
|
-
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1378
|
-
_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1379
|
-
skip = /^value(?:Change)?$/;
|
|
1380
|
-
}
|
|
1381
|
-
break;
|
|
1382
|
-
case "DETAILS":
|
|
1383
|
-
case "DIALOG":
|
|
1384
|
-
if ("open" in nextAttrs || "openChange" in nextAttrs) {
|
|
1385
|
-
_attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange);
|
|
1386
|
-
skip = /^open(?:Change)?$/;
|
|
1387
|
-
}
|
|
1388
|
-
break;
|
|
1389
|
-
}
|
|
1390
|
-
for (const name in nextAttrs) {
|
|
1391
|
-
const value = nextAttrs[name];
|
|
1392
|
-
switch (name) {
|
|
1393
|
-
case "class":
|
|
1394
|
-
_attr_class(el, value);
|
|
1395
|
-
break;
|
|
1396
|
-
case "style":
|
|
1397
|
-
_attr_style(el, value);
|
|
1398
|
-
break;
|
|
1399
|
-
default:
|
|
1400
|
-
assertValidAttrName(name);
|
|
1401
|
-
if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1402
|
-
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1403
|
-
break;
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
function _attr_content(scope, nodeAccessor, value) {
|
|
1408
|
-
const content = normalizeClientRender(value);
|
|
1409
|
-
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
|
|
1410
|
-
setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1411
|
-
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
1479
|
+
function _controllable_input(scope, nodeAccessor, nextAttrs) {
|
|
1480
|
+
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
|
|
1481
|
+
_attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
1482
|
+
return /^checked(?:Value)?(?:Change)?$/;
|
|
1412
1483
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
const el = scope[nodeAccessor];
|
|
1417
|
-
const events = scope[EventAttributes + nodeAccessor];
|
|
1418
|
-
switch (scope[ControlledType + nodeAccessor]) {
|
|
1419
|
-
case 0:
|
|
1420
|
-
_attr_input_checked_script(scope, nodeAccessor);
|
|
1421
|
-
break;
|
|
1422
|
-
case 1:
|
|
1423
|
-
_attr_input_checkedValue_script(scope, nodeAccessor);
|
|
1424
|
-
break;
|
|
1425
|
-
case 2:
|
|
1426
|
-
_attr_input_value_script(scope, nodeAccessor);
|
|
1427
|
-
break;
|
|
1428
|
-
case 3:
|
|
1429
|
-
_attr_select_value_script(scope, nodeAccessor);
|
|
1430
|
-
break;
|
|
1431
|
-
case 4:
|
|
1432
|
-
_attr_details_or_dialog_open_script(scope, nodeAccessor);
|
|
1433
|
-
break;
|
|
1484
|
+
if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
|
|
1485
|
+
_attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
|
1486
|
+
return /^(?:value|checked(?:Value)?)(?:Change)?$/;
|
|
1434
1487
|
}
|
|
1435
|
-
|
|
1436
|
-
}
|
|
1437
|
-
function _html(scope, value, accessor) {
|
|
1438
|
-
const firstChild = scope[accessor];
|
|
1439
|
-
const parentNode = firstChild.parentNode;
|
|
1440
|
-
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1441
|
-
const newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
|
|
1442
|
-
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope[DynamicHTMLLastChild + accessor] = newContent.lastChild);
|
|
1443
|
-
removeChildNodes(firstChild, lastChild);
|
|
1444
|
-
}
|
|
1445
|
-
function normalizeClientRender(value) {
|
|
1446
|
-
const renderer = normalizeDynamicRenderer(value);
|
|
1447
|
-
if (renderer) if (renderer["id"]) return renderer;
|
|
1448
|
-
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1449
|
-
}
|
|
1450
|
-
function normalizeAttrValue(value) {
|
|
1451
|
-
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
1488
|
+
return _controllable_textarea(scope, nodeAccessor, nextAttrs, _attr_input_value_dynamic_default);
|
|
1452
1489
|
}
|
|
1453
|
-
function
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
Object.assign(instance, thisObj);
|
|
1458
|
-
instance.onUpdate?.();
|
|
1459
|
-
} else {
|
|
1460
|
-
scope[accessor] = thisObj;
|
|
1461
|
-
{
|
|
1462
|
-
const snapshot = { ...thisObj };
|
|
1463
|
-
Object.assign(thisObj, thisObj.onMount?.());
|
|
1464
|
-
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1465
|
-
}
|
|
1466
|
-
$signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
|
|
1490
|
+
function _controllable_textarea(scope, nodeAccessor, nextAttrs, dynamicDefault) {
|
|
1491
|
+
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1492
|
+
_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, dynamicDefault);
|
|
1493
|
+
return /^value(?:Change)?$/;
|
|
1467
1494
|
}
|
|
1468
1495
|
}
|
|
1469
|
-
function
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
startNode.remove();
|
|
1474
|
-
startNode = next;
|
|
1496
|
+
function _controllable_select(scope, nodeAccessor, nextAttrs) {
|
|
1497
|
+
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1498
|
+
_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1499
|
+
return /^value(?:Change)?$/;
|
|
1475
1500
|
}
|
|
1476
1501
|
}
|
|
1477
|
-
function
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
if (startNode === endNode) return startNode;
|
|
1482
|
-
const parent = new DocumentFragment();
|
|
1483
|
-
const stop = endNode.nextSibling;
|
|
1484
|
-
while (startNode !== stop) {
|
|
1485
|
-
const next = startNode.nextSibling;
|
|
1486
|
-
parent.appendChild(startNode);
|
|
1487
|
-
startNode = next;
|
|
1502
|
+
function _controllable_open(scope, nodeAccessor, nextAttrs) {
|
|
1503
|
+
if ("open" in nextAttrs || "openChange" in nextAttrs) {
|
|
1504
|
+
_attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange);
|
|
1505
|
+
return /^open(?:Change)?$/;
|
|
1488
1506
|
}
|
|
1489
|
-
return parent;
|
|
1490
1507
|
}
|
|
1491
1508
|
//#endregion
|
|
1492
1509
|
//#region src/dom/control-flow.ts
|
|
@@ -1545,6 +1562,11 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1545
1562
|
if (thisPromise === scope[promiseAccessor]) {
|
|
1546
1563
|
const referenceNode = scope[nodeAccessor];
|
|
1547
1564
|
scope[promiseAccessor] = 0;
|
|
1565
|
+
if (scope["#ClosestBranch"]?.["#Gen"] === 0) {
|
|
1566
|
+
awaitCounter.c();
|
|
1567
|
+
run();
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1548
1570
|
queueAsyncRender(scope, () => {
|
|
1549
1571
|
awaitBranch = resolveAwait(scope, referenceNode, data);
|
|
1550
1572
|
const pendingRenders = awaitBranch[PendingRenders];
|
|
@@ -1722,8 +1744,9 @@ let _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
|
|
|
1722
1744
|
const childScope = scope[childScopeAccessor];
|
|
1723
1745
|
const args = getInput?.();
|
|
1724
1746
|
if (typeof normalizedRenderer === "string") {
|
|
1725
|
-
|
|
1726
|
-
|
|
1747
|
+
const nodeAccessor = `#${normalizedRenderer}/0`;
|
|
1748
|
+
(getContent ? _attrs : _attrs_content)(childScope, nodeAccessor, (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope[nodeAccessor].tagName]);
|
|
1749
|
+
if (childScope["EventAttributes:" + nodeAccessor] || childScope["ControlledHandler:" + nodeAccessor]) queueEffect(childScope, dynamicTagScript);
|
|
1727
1750
|
} else {
|
|
1728
1751
|
for (const accessor in normalizedRenderer[LocalClosures]) normalizedRenderer[LocalClosures][accessor](childScope, normalizedRenderer[LocalClosureValues][accessor]);
|
|
1729
1752
|
if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
|
|
@@ -2053,8 +2076,9 @@ function _enable_catch() {
|
|
|
2053
2076
|
function $signalReset(scope, id) {
|
|
2054
2077
|
const ctrl = scope[AbortControllers]?.[id];
|
|
2055
2078
|
if (ctrl) {
|
|
2056
|
-
queueEffect(ctrl, abort);
|
|
2057
2079
|
scope[AbortControllers][id] = void 0;
|
|
2080
|
+
if (rendering) queueEffect(ctrl, abort);
|
|
2081
|
+
else abort(ctrl);
|
|
2058
2082
|
}
|
|
2059
2083
|
}
|
|
2060
2084
|
function $signal(scope, id) {
|
|
@@ -2217,10 +2241,13 @@ function mount(input = {}, reference, position) {
|
|
|
2217
2241
|
set value(newValue) {
|
|
2218
2242
|
_var_change(branch, newValue);
|
|
2219
2243
|
},
|
|
2220
|
-
update(newInput) {
|
|
2221
|
-
if (args)
|
|
2222
|
-
|
|
2223
|
-
|
|
2244
|
+
update(newInput = {}) {
|
|
2245
|
+
if (args) {
|
|
2246
|
+
if (newInput.$global) ({$global, ...newInput} = newInput);
|
|
2247
|
+
runEffects(prepareEffects(() => {
|
|
2248
|
+
args(branch, newInput);
|
|
2249
|
+
}));
|
|
2250
|
+
}
|
|
2224
2251
|
},
|
|
2225
2252
|
destroy() {
|
|
2226
2253
|
removeAndDestroyBranch(branch);
|
|
@@ -2329,4 +2356,4 @@ function getSelectorOrResolve(selector, resolve) {
|
|
|
2329
2356
|
return document.querySelector(selector) || (console.warn(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`), resolve());
|
|
2330
2357
|
}
|
|
2331
2358
|
//#endregion
|
|
2332
|
-
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
|
|
2359
|
+
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _enable_controllable, _enable_controllable_input, _enable_controllable_open, _enable_controllable_select, _enable_controllable_textarea, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
|