marko 6.1.18 → 6.1.20
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/debug/dom.js +35 -39
- package/dist/debug/dom.mjs +35 -39
- package/dist/debug/html.js +37 -25
- package/dist/debug/html.mjs +37 -25
- package/dist/dom/event.d.ts +1 -1
- package/dist/dom.js +18 -30
- package/dist/dom.mjs +18 -30
- package/dist/html/attrs.d.ts +6 -6
- package/dist/html.js +29 -26
- package/dist/html.mjs +29 -26
- package/dist/translator/index.js +47 -38
- package/dist/translator/visitors/tag/dynamic-tag.d.ts +1 -0
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
|
@@ -230,19 +230,12 @@ function push(opt, item) {
|
|
|
230
230
|
}
|
|
231
231
|
//#endregion
|
|
232
232
|
//#region src/dom/event.ts
|
|
233
|
-
const defaultDelegator = /* @__PURE__ */ createDelegator();
|
|
234
233
|
function _on(element, type, handler) {
|
|
235
234
|
assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
|
|
236
|
-
if (element["$" + type] === void 0)
|
|
235
|
+
if (element["$" + type] === void 0) delegate(type, handleDelegated);
|
|
237
236
|
element["$" + type] = handler || null;
|
|
238
237
|
}
|
|
239
|
-
|
|
240
|
-
function createDelegator() {
|
|
241
|
-
const kEvents = Symbol();
|
|
242
|
-
return function ensureDelegated(node, type, handler) {
|
|
243
|
-
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, true), 1);
|
|
244
|
-
};
|
|
245
|
-
}
|
|
238
|
+
const delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, true), 1);
|
|
246
239
|
function handleDelegated(ev) {
|
|
247
240
|
let target = !rendering && ev.target;
|
|
248
241
|
Object.defineProperty(ev, "currentTarget", {
|
|
@@ -867,7 +860,6 @@ function _el(id, accessor) {
|
|
|
867
860
|
//#endregion
|
|
868
861
|
//#region src/dom/controllable.ts
|
|
869
862
|
let inputType = "";
|
|
870
|
-
const controllableDelegate = /* @__PURE__ */ createDelegator();
|
|
871
863
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
872
864
|
const el = scope[nodeAccessor];
|
|
873
865
|
const normalizedChecked = isNotVoid(checked);
|
|
@@ -927,7 +919,7 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
|
927
919
|
const oldValue = scope["ControlledValue:" + nodeAccessor];
|
|
928
920
|
const newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
|
|
929
921
|
if (el.name && el.type[0] === "r") {
|
|
930
|
-
for (const radio of
|
|
922
|
+
for (const radio of document.querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
|
|
931
923
|
} else el.checked = !el.checked;
|
|
932
924
|
checkedValueChange(newValue);
|
|
933
925
|
run();
|
|
@@ -969,7 +961,7 @@ function _attr_input_value_script(scope, nodeAccessor) {
|
|
|
969
961
|
}
|
|
970
962
|
function setInputValue(el, value) {
|
|
971
963
|
if (el.value !== value) {
|
|
972
|
-
const updatedPosition = resolveCursorPosition(inputType,
|
|
964
|
+
const updatedPosition = resolveCursorPosition(inputType, document.activeElement === el && el.selectionStart, el.value, el.value = value);
|
|
973
965
|
if (~updatedPosition) el.setSelectionRange(updatedPosition, updatedPosition);
|
|
974
966
|
}
|
|
975
967
|
}
|
|
@@ -1076,8 +1068,8 @@ function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
|
1076
1068
|
}
|
|
1077
1069
|
function syncControllableFormInput(el, hasChanged, onChange) {
|
|
1078
1070
|
el._ = onChange;
|
|
1079
|
-
|
|
1080
|
-
if (el.form)
|
|
1071
|
+
delegate("input", handleChange);
|
|
1072
|
+
if (el.form) delegate("reset", handleFormReset);
|
|
1081
1073
|
if (isResuming && hasChanged(el)) queueMicrotask(onChange);
|
|
1082
1074
|
}
|
|
1083
1075
|
function handleChange(ev) {
|
|
@@ -1198,11 +1190,16 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
|
1198
1190
|
scope["ControlledHandler:" + nodeAccessor] = 0;
|
|
1199
1191
|
switch (el.tagName) {
|
|
1200
1192
|
case "INPUT":
|
|
1201
|
-
if ("checked" in nextAttrs || "checkedChange" in nextAttrs)
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
else
|
|
1205
|
-
|
|
1193
|
+
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
|
|
1194
|
+
_attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
1195
|
+
skip = /^checked(?:Value)?(?:Change)?$/;
|
|
1196
|
+
} else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
|
|
1197
|
+
_attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
|
1198
|
+
skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
|
|
1199
|
+
} else if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1200
|
+
_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1201
|
+
skip = /^value(?:Change)?$/;
|
|
1202
|
+
} else break;
|
|
1206
1203
|
break;
|
|
1207
1204
|
case "SELECT":
|
|
1208
1205
|
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
@@ -1933,7 +1930,7 @@ const compat = {
|
|
|
1933
1930
|
component.scope = branch;
|
|
1934
1931
|
classIdToBranch.delete(component.id);
|
|
1935
1932
|
}
|
|
1936
|
-
if (typeof args[0] === "object" && "renderBody" in args[0]) {
|
|
1933
|
+
if (args[0] && typeof args[0] === "object" && "renderBody" in args[0]) {
|
|
1937
1934
|
const input = args[0];
|
|
1938
1935
|
const normalizedInput = args[0] = {};
|
|
1939
1936
|
for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
@@ -2052,35 +2049,34 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
2052
2049
|
};
|
|
2053
2050
|
}
|
|
2054
2051
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
2055
|
-
const parent = marker.parentNode
|
|
2056
|
-
syncGen(branch);
|
|
2057
|
-
renderer["clone"](branch, parent.namespaceURI);
|
|
2058
|
-
setupBranch(renderer, branch);
|
|
2059
|
-
applyLoad(branch, () => {
|
|
2052
|
+
const parent = marker.parentNode, values = branch["#Load"], insert = () => {
|
|
2060
2053
|
insertBranchBefore(branch, parent, marker);
|
|
2061
2054
|
marker.remove();
|
|
2062
2055
|
awaitCounter?.c();
|
|
2063
|
-
});
|
|
2064
|
-
}
|
|
2065
|
-
function loadFailed(scope, awaitCounter) {
|
|
2066
|
-
return (error) => {
|
|
2067
|
-
if (awaitCounter) awaitCounter.i = 0;
|
|
2068
|
-
queueAsyncRender(scope, renderCatch, error);
|
|
2069
2056
|
};
|
|
2070
|
-
}
|
|
2071
|
-
function applyLoad(scope, insert) {
|
|
2072
|
-
const values = scope["#Load"];
|
|
2073
2057
|
let remaining;
|
|
2074
|
-
|
|
2058
|
+
syncGen(branch);
|
|
2059
|
+
renderer["clone"](branch, parent.namespaceURI);
|
|
2060
|
+
branch["#Load"] = 0;
|
|
2075
2061
|
if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
|
|
2076
2062
|
entry["signal"] = signal;
|
|
2077
|
-
if (!--remaining) queueAsyncRender(
|
|
2078
|
-
syncGen(
|
|
2079
|
-
|
|
2063
|
+
if (!--remaining) queueAsyncRender(branch, (branch) => {
|
|
2064
|
+
syncGen(branch);
|
|
2065
|
+
renderer["setup"]?.(branch);
|
|
2066
|
+
values.forEach((e) => e["signal"]._(branch, e["value"]));
|
|
2080
2067
|
insert();
|
|
2081
2068
|
});
|
|
2082
2069
|
}, () => 0);
|
|
2083
|
-
else
|
|
2070
|
+
else {
|
|
2071
|
+
setupBranch(renderer, branch);
|
|
2072
|
+
insert();
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
function loadFailed(scope, awaitCounter) {
|
|
2076
|
+
return (error) => {
|
|
2077
|
+
if (awaitCounter) awaitCounter.i = 0;
|
|
2078
|
+
queueAsyncRender(scope, renderCatch, error);
|
|
2079
|
+
};
|
|
2084
2080
|
}
|
|
2085
2081
|
function _load_signal(load) {
|
|
2086
2082
|
let pending;
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -228,19 +228,12 @@ function push(opt, item) {
|
|
|
228
228
|
}
|
|
229
229
|
//#endregion
|
|
230
230
|
//#region src/dom/event.ts
|
|
231
|
-
const defaultDelegator = /* @__PURE__ */ createDelegator();
|
|
232
231
|
function _on(element, type, handler) {
|
|
233
232
|
assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
|
|
234
|
-
if (element["$" + type] === void 0)
|
|
233
|
+
if (element["$" + type] === void 0) delegate(type, handleDelegated);
|
|
235
234
|
element["$" + type] = handler || null;
|
|
236
235
|
}
|
|
237
|
-
|
|
238
|
-
function createDelegator() {
|
|
239
|
-
const kEvents = Symbol();
|
|
240
|
-
return function ensureDelegated(node, type, handler) {
|
|
241
|
-
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, true), 1);
|
|
242
|
-
};
|
|
243
|
-
}
|
|
236
|
+
const delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, true), 1);
|
|
244
237
|
function handleDelegated(ev) {
|
|
245
238
|
let target = !rendering && ev.target;
|
|
246
239
|
Object.defineProperty(ev, "currentTarget", {
|
|
@@ -865,7 +858,6 @@ function _el(id, accessor) {
|
|
|
865
858
|
//#endregion
|
|
866
859
|
//#region src/dom/controllable.ts
|
|
867
860
|
let inputType = "";
|
|
868
|
-
const controllableDelegate = /* @__PURE__ */ createDelegator();
|
|
869
861
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
870
862
|
const el = scope[nodeAccessor];
|
|
871
863
|
const normalizedChecked = isNotVoid(checked);
|
|
@@ -925,7 +917,7 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
|
925
917
|
const oldValue = scope["ControlledValue:" + nodeAccessor];
|
|
926
918
|
const newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
|
|
927
919
|
if (el.name && el.type[0] === "r") {
|
|
928
|
-
for (const radio of
|
|
920
|
+
for (const radio of document.querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
|
|
929
921
|
} else el.checked = !el.checked;
|
|
930
922
|
checkedValueChange(newValue);
|
|
931
923
|
run();
|
|
@@ -967,7 +959,7 @@ function _attr_input_value_script(scope, nodeAccessor) {
|
|
|
967
959
|
}
|
|
968
960
|
function setInputValue(el, value) {
|
|
969
961
|
if (el.value !== value) {
|
|
970
|
-
const updatedPosition = resolveCursorPosition(inputType,
|
|
962
|
+
const updatedPosition = resolveCursorPosition(inputType, document.activeElement === el && el.selectionStart, el.value, el.value = value);
|
|
971
963
|
if (~updatedPosition) el.setSelectionRange(updatedPosition, updatedPosition);
|
|
972
964
|
}
|
|
973
965
|
}
|
|
@@ -1074,8 +1066,8 @@ function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
|
1074
1066
|
}
|
|
1075
1067
|
function syncControllableFormInput(el, hasChanged, onChange) {
|
|
1076
1068
|
el._ = onChange;
|
|
1077
|
-
|
|
1078
|
-
if (el.form)
|
|
1069
|
+
delegate("input", handleChange);
|
|
1070
|
+
if (el.form) delegate("reset", handleFormReset);
|
|
1079
1071
|
if (isResuming && hasChanged(el)) queueMicrotask(onChange);
|
|
1080
1072
|
}
|
|
1081
1073
|
function handleChange(ev) {
|
|
@@ -1196,11 +1188,16 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
|
1196
1188
|
scope["ControlledHandler:" + nodeAccessor] = 0;
|
|
1197
1189
|
switch (el.tagName) {
|
|
1198
1190
|
case "INPUT":
|
|
1199
|
-
if ("checked" in nextAttrs || "checkedChange" in nextAttrs)
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
else
|
|
1203
|
-
|
|
1191
|
+
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
|
|
1192
|
+
_attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
1193
|
+
skip = /^checked(?:Value)?(?:Change)?$/;
|
|
1194
|
+
} else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
|
|
1195
|
+
_attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
|
1196
|
+
skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
|
|
1197
|
+
} else if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1198
|
+
_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1199
|
+
skip = /^value(?:Change)?$/;
|
|
1200
|
+
} else break;
|
|
1204
1201
|
break;
|
|
1205
1202
|
case "SELECT":
|
|
1206
1203
|
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
@@ -1931,7 +1928,7 @@ const compat = {
|
|
|
1931
1928
|
component.scope = branch;
|
|
1932
1929
|
classIdToBranch.delete(component.id);
|
|
1933
1930
|
}
|
|
1934
|
-
if (typeof args[0] === "object" && "renderBody" in args[0]) {
|
|
1931
|
+
if (args[0] && typeof args[0] === "object" && "renderBody" in args[0]) {
|
|
1935
1932
|
const input = args[0];
|
|
1936
1933
|
const normalizedInput = args[0] = {};
|
|
1937
1934
|
for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
@@ -2050,35 +2047,34 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
2050
2047
|
};
|
|
2051
2048
|
}
|
|
2052
2049
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
2053
|
-
const parent = marker.parentNode
|
|
2054
|
-
syncGen(branch);
|
|
2055
|
-
renderer["clone"](branch, parent.namespaceURI);
|
|
2056
|
-
setupBranch(renderer, branch);
|
|
2057
|
-
applyLoad(branch, () => {
|
|
2050
|
+
const parent = marker.parentNode, values = branch["#Load"], insert = () => {
|
|
2058
2051
|
insertBranchBefore(branch, parent, marker);
|
|
2059
2052
|
marker.remove();
|
|
2060
2053
|
awaitCounter?.c();
|
|
2061
|
-
});
|
|
2062
|
-
}
|
|
2063
|
-
function loadFailed(scope, awaitCounter) {
|
|
2064
|
-
return (error) => {
|
|
2065
|
-
if (awaitCounter) awaitCounter.i = 0;
|
|
2066
|
-
queueAsyncRender(scope, renderCatch, error);
|
|
2067
2054
|
};
|
|
2068
|
-
}
|
|
2069
|
-
function applyLoad(scope, insert) {
|
|
2070
|
-
const values = scope["#Load"];
|
|
2071
2055
|
let remaining;
|
|
2072
|
-
|
|
2056
|
+
syncGen(branch);
|
|
2057
|
+
renderer["clone"](branch, parent.namespaceURI);
|
|
2058
|
+
branch["#Load"] = 0;
|
|
2073
2059
|
if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
|
|
2074
2060
|
entry["signal"] = signal;
|
|
2075
|
-
if (!--remaining) queueAsyncRender(
|
|
2076
|
-
syncGen(
|
|
2077
|
-
|
|
2061
|
+
if (!--remaining) queueAsyncRender(branch, (branch) => {
|
|
2062
|
+
syncGen(branch);
|
|
2063
|
+
renderer["setup"]?.(branch);
|
|
2064
|
+
values.forEach((e) => e["signal"]._(branch, e["value"]));
|
|
2078
2065
|
insert();
|
|
2079
2066
|
});
|
|
2080
2067
|
}, () => 0);
|
|
2081
|
-
else
|
|
2068
|
+
else {
|
|
2069
|
+
setupBranch(renderer, branch);
|
|
2070
|
+
insert();
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
function loadFailed(scope, awaitCounter) {
|
|
2074
|
+
return (error) => {
|
|
2075
|
+
if (awaitCounter) awaitCounter.i = 0;
|
|
2076
|
+
queueAsyncRender(scope, renderCatch, error);
|
|
2077
|
+
};
|
|
2082
2078
|
}
|
|
2083
2079
|
function _load_signal(load) {
|
|
2084
2080
|
let pending;
|
package/dist/debug/html.js
CHANGED
|
@@ -877,8 +877,11 @@ function writeDate(state, val) {
|
|
|
877
877
|
state.buf.push("new Date(" + +val + ")");
|
|
878
878
|
return true;
|
|
879
879
|
}
|
|
880
|
+
const unsafeRegExpSourceReg = /\\[\s\S]|</g;
|
|
881
|
+
const replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match;
|
|
880
882
|
function writeRegExp(state, val) {
|
|
881
|
-
|
|
883
|
+
const { source } = val;
|
|
884
|
+
state.buf.push("/" + (source.includes("<") ? source.replace(unsafeRegExpSourceReg, replaceUnsafeRegExpSourceChar) : source) + "/" + val.flags);
|
|
882
885
|
return true;
|
|
883
886
|
}
|
|
884
887
|
function writePromise(state, val, ref) {
|
|
@@ -1008,7 +1011,7 @@ function writeWeakMap(state) {
|
|
|
1008
1011
|
}
|
|
1009
1012
|
function writeError(state, val, ref) {
|
|
1010
1013
|
const result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
|
|
1011
|
-
if (val.cause) {
|
|
1014
|
+
if (val.cause !== void 0) {
|
|
1012
1015
|
state.buf.push(result + ",{cause:");
|
|
1013
1016
|
writeProp(state, val.cause, ref, "cause");
|
|
1014
1017
|
state.buf.push("})");
|
|
@@ -2464,7 +2467,8 @@ function _attr_style(value) {
|
|
|
2464
2467
|
}
|
|
2465
2468
|
function _attr_option_value(value) {
|
|
2466
2469
|
const valueAttr = _attr("value", value);
|
|
2467
|
-
|
|
2470
|
+
const selectedValue = getContext(kSelectedValue);
|
|
2471
|
+
if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) {
|
|
2468
2472
|
{
|
|
2469
2473
|
const matched = getContext(kSelectedValueMatched);
|
|
2470
2474
|
if (matched) matched.value = true;
|
|
@@ -2475,29 +2479,29 @@ function _attr_option_value(value) {
|
|
|
2475
2479
|
}
|
|
2476
2480
|
const kSelectedValue = Symbol("selectedValue");
|
|
2477
2481
|
const kSelectedValueMatched = Symbol("selectedValueMatched");
|
|
2478
|
-
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
|
2479
|
-
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange);
|
|
2482
|
+
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
|
|
2483
|
+
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2480
2484
|
if (content) if (valueChange) {
|
|
2481
2485
|
const matched = { value: false };
|
|
2482
2486
|
withContext(kSelectedValue, value, () => withContext(kSelectedValueMatched, matched, content));
|
|
2483
2487
|
if (!matched.value && (Array.isArray(value) ? value.some((v) => normalizeStrAttrValue(v) !== "") : normalizeStrAttrValue(value) !== "")) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
|
|
2484
2488
|
} else withContext(kSelectedValue, value, content);
|
|
2485
2489
|
}
|
|
2486
|
-
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
|
2487
|
-
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
|
|
2490
|
+
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2491
|
+
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2488
2492
|
return _escape(value);
|
|
2489
2493
|
}
|
|
2490
|
-
function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
|
|
2491
|
-
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
|
|
2494
|
+
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2495
|
+
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2492
2496
|
return _attr("value", value);
|
|
2493
2497
|
}
|
|
2494
|
-
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
|
|
2495
|
-
if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange);
|
|
2498
|
+
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
|
|
2499
|
+
if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
|
|
2496
2500
|
return isNotVoid(checked) ? " checked" : "";
|
|
2497
2501
|
}
|
|
2498
|
-
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
2502
|
+
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
|
|
2499
2503
|
const valueAttr = _attr("value", value);
|
|
2500
|
-
if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange);
|
|
2504
|
+
if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
|
|
2501
2505
|
return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
|
|
2502
2506
|
}
|
|
2503
2507
|
const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2511,9 +2515,9 @@ function getCheckedValueRef(checkedValue) {
|
|
|
2511
2515
|
return ref;
|
|
2512
2516
|
}
|
|
2513
2517
|
}
|
|
2514
|
-
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
|
|
2518
|
+
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
|
|
2515
2519
|
const normalizedOpen = isNotVoid(open);
|
|
2516
|
-
if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange);
|
|
2520
|
+
if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
|
|
2517
2521
|
return normalizedOpen ? " open" : "";
|
|
2518
2522
|
}
|
|
2519
2523
|
function _attr_nonce() {
|
|
@@ -2529,11 +2533,16 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
2529
2533
|
switch (tagName) {
|
|
2530
2534
|
case "input":
|
|
2531
2535
|
assertExclusiveAttrs(data);
|
|
2532
|
-
if (data.checkedChange)
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
else
|
|
2536
|
-
|
|
2536
|
+
if (data.checkedChange) {
|
|
2537
|
+
result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
|
|
2538
|
+
skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
|
|
2539
|
+
} else if ("checkedValue" in data || data.checkedValueChange) {
|
|
2540
|
+
result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
|
|
2541
|
+
skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
|
|
2542
|
+
} else if (data.valueChange) {
|
|
2543
|
+
result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
|
|
2544
|
+
skip = /^value(?:Change)?$|[\s/>"'=]/;
|
|
2545
|
+
} else break;
|
|
2537
2546
|
break;
|
|
2538
2547
|
case "select":
|
|
2539
2548
|
case "textarea":
|
|
@@ -2548,7 +2557,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
2548
2557
|
case "details":
|
|
2549
2558
|
case "dialog":
|
|
2550
2559
|
if (data.openChange) {
|
|
2551
|
-
result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange);
|
|
2560
|
+
result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
|
|
2552
2561
|
skip = /^open(?:Change)?$|[\s/>"'=]/;
|
|
2553
2562
|
}
|
|
2554
2563
|
break;
|
|
@@ -2594,12 +2603,15 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
|
|
|
2594
2603
|
_html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`);
|
|
2595
2604
|
_attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
|
|
2596
2605
|
}
|
|
2597
|
-
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
|
|
2606
|
+
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2598
2607
|
assertHandlerIsFunction("valueChange", valueChange);
|
|
2599
|
-
writeScope(scopeId, {
|
|
2608
|
+
writeScope(scopeId, serializeType ? {
|
|
2600
2609
|
["ControlledType:" + nodeAccessor]: type,
|
|
2601
2610
|
["ControlledValue:" + nodeAccessor]: value,
|
|
2602
2611
|
["ControlledHandler:" + nodeAccessor]: valueChange
|
|
2612
|
+
} : {
|
|
2613
|
+
["ControlledValue:" + nodeAccessor]: value,
|
|
2614
|
+
["ControlledHandler:" + nodeAccessor]: valueChange
|
|
2603
2615
|
});
|
|
2604
2616
|
}
|
|
2605
2617
|
function stringAttr(name, value) {
|
|
@@ -2665,10 +2677,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2665
2677
|
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
2666
2678
|
if (renderer === "textarea") {
|
|
2667
2679
|
if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
|
|
2668
|
-
_html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange));
|
|
2680
|
+
_html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
|
|
2669
2681
|
} else if (renderContent) {
|
|
2670
2682
|
if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2671
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent);
|
|
2683
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
|
|
2672
2684
|
else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
|
|
2673
2685
|
}
|
|
2674
2686
|
_html(`</${renderer}>`);
|
package/dist/debug/html.mjs
CHANGED
|
@@ -875,8 +875,11 @@ function writeDate(state, val) {
|
|
|
875
875
|
state.buf.push("new Date(" + +val + ")");
|
|
876
876
|
return true;
|
|
877
877
|
}
|
|
878
|
+
const unsafeRegExpSourceReg = /\\[\s\S]|</g;
|
|
879
|
+
const replaceUnsafeRegExpSourceChar = (match) => match === "<" || match === "\\<" ? "\\x3C" : match;
|
|
878
880
|
function writeRegExp(state, val) {
|
|
879
|
-
|
|
881
|
+
const { source } = val;
|
|
882
|
+
state.buf.push("/" + (source.includes("<") ? source.replace(unsafeRegExpSourceReg, replaceUnsafeRegExpSourceChar) : source) + "/" + val.flags);
|
|
880
883
|
return true;
|
|
881
884
|
}
|
|
882
885
|
function writePromise(state, val, ref) {
|
|
@@ -1006,7 +1009,7 @@ function writeWeakMap(state) {
|
|
|
1006
1009
|
}
|
|
1007
1010
|
function writeError(state, val, ref) {
|
|
1008
1011
|
const result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
|
|
1009
|
-
if (val.cause) {
|
|
1012
|
+
if (val.cause !== void 0) {
|
|
1010
1013
|
state.buf.push(result + ",{cause:");
|
|
1011
1014
|
writeProp(state, val.cause, ref, "cause");
|
|
1012
1015
|
state.buf.push("})");
|
|
@@ -2462,7 +2465,8 @@ function _attr_style(value) {
|
|
|
2462
2465
|
}
|
|
2463
2466
|
function _attr_option_value(value) {
|
|
2464
2467
|
const valueAttr = _attr("value", value);
|
|
2465
|
-
|
|
2468
|
+
const selectedValue = getContext(kSelectedValue);
|
|
2469
|
+
if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) {
|
|
2466
2470
|
{
|
|
2467
2471
|
const matched = getContext(kSelectedValueMatched);
|
|
2468
2472
|
if (matched) matched.value = true;
|
|
@@ -2473,29 +2477,29 @@ function _attr_option_value(value) {
|
|
|
2473
2477
|
}
|
|
2474
2478
|
const kSelectedValue = Symbol("selectedValue");
|
|
2475
2479
|
const kSelectedValueMatched = Symbol("selectedValueMatched");
|
|
2476
|
-
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
|
2477
|
-
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange);
|
|
2480
|
+
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
|
|
2481
|
+
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2478
2482
|
if (content) if (valueChange) {
|
|
2479
2483
|
const matched = { value: false };
|
|
2480
2484
|
withContext(kSelectedValue, value, () => withContext(kSelectedValueMatched, matched, content));
|
|
2481
2485
|
if (!matched.value && (Array.isArray(value) ? value.some((v) => normalizeStrAttrValue(v) !== "") : normalizeStrAttrValue(value) !== "")) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
|
|
2482
2486
|
} else withContext(kSelectedValue, value, content);
|
|
2483
2487
|
}
|
|
2484
|
-
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
|
2485
|
-
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
|
|
2488
|
+
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2489
|
+
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2486
2490
|
return _escape(value);
|
|
2487
2491
|
}
|
|
2488
|
-
function _attr_input_value(scopeId, nodeAccessor, value, valueChange) {
|
|
2489
|
-
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange);
|
|
2492
|
+
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2493
|
+
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2490
2494
|
return _attr("value", value);
|
|
2491
2495
|
}
|
|
2492
|
-
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
|
|
2493
|
-
if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange);
|
|
2496
|
+
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
|
|
2497
|
+
if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
|
|
2494
2498
|
return isNotVoid(checked) ? " checked" : "";
|
|
2495
2499
|
}
|
|
2496
|
-
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
2500
|
+
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
|
|
2497
2501
|
const valueAttr = _attr("value", value);
|
|
2498
|
-
if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange);
|
|
2502
|
+
if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
|
|
2499
2503
|
return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
|
|
2500
2504
|
}
|
|
2501
2505
|
const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
|
|
@@ -2509,9 +2513,9 @@ function getCheckedValueRef(checkedValue) {
|
|
|
2509
2513
|
return ref;
|
|
2510
2514
|
}
|
|
2511
2515
|
}
|
|
2512
|
-
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
|
|
2516
|
+
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
|
|
2513
2517
|
const normalizedOpen = isNotVoid(open);
|
|
2514
|
-
if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange);
|
|
2518
|
+
if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
|
|
2515
2519
|
return normalizedOpen ? " open" : "";
|
|
2516
2520
|
}
|
|
2517
2521
|
function _attr_nonce() {
|
|
@@ -2527,11 +2531,16 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
2527
2531
|
switch (tagName) {
|
|
2528
2532
|
case "input":
|
|
2529
2533
|
assertExclusiveAttrs(data);
|
|
2530
|
-
if (data.checkedChange)
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
else
|
|
2534
|
-
|
|
2534
|
+
if (data.checkedChange) {
|
|
2535
|
+
result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
|
|
2536
|
+
skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
|
|
2537
|
+
} else if ("checkedValue" in data || data.checkedValueChange) {
|
|
2538
|
+
result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
|
|
2539
|
+
skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
|
|
2540
|
+
} else if (data.valueChange) {
|
|
2541
|
+
result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
|
|
2542
|
+
skip = /^value(?:Change)?$|[\s/>"'=]/;
|
|
2543
|
+
} else break;
|
|
2535
2544
|
break;
|
|
2536
2545
|
case "select":
|
|
2537
2546
|
case "textarea":
|
|
@@ -2546,7 +2555,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
2546
2555
|
case "details":
|
|
2547
2556
|
case "dialog":
|
|
2548
2557
|
if (data.openChange) {
|
|
2549
|
-
result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange);
|
|
2558
|
+
result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
|
|
2550
2559
|
skip = /^open(?:Change)?$|[\s/>"'=]/;
|
|
2551
2560
|
}
|
|
2552
2561
|
break;
|
|
@@ -2592,12 +2601,15 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
|
|
|
2592
2601
|
_html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`);
|
|
2593
2602
|
_attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
|
|
2594
2603
|
}
|
|
2595
|
-
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
|
|
2604
|
+
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2596
2605
|
assertHandlerIsFunction("valueChange", valueChange);
|
|
2597
|
-
writeScope(scopeId, {
|
|
2606
|
+
writeScope(scopeId, serializeType ? {
|
|
2598
2607
|
["ControlledType:" + nodeAccessor]: type,
|
|
2599
2608
|
["ControlledValue:" + nodeAccessor]: value,
|
|
2600
2609
|
["ControlledHandler:" + nodeAccessor]: valueChange
|
|
2610
|
+
} : {
|
|
2611
|
+
["ControlledValue:" + nodeAccessor]: value,
|
|
2612
|
+
["ControlledHandler:" + nodeAccessor]: valueChange
|
|
2601
2613
|
});
|
|
2602
2614
|
}
|
|
2603
2615
|
function stringAttr(name, value) {
|
|
@@ -2663,10 +2675,10 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2663
2675
|
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
2664
2676
|
if (renderer === "textarea") {
|
|
2665
2677
|
if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
|
|
2666
|
-
_html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange));
|
|
2678
|
+
_html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
|
|
2667
2679
|
} else if (renderContent) {
|
|
2668
2680
|
if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2669
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent);
|
|
2681
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
|
|
2670
2682
|
else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
|
|
2671
2683
|
}
|
|
2672
2684
|
_html(`</${renderer}>`);
|
package/dist/dom/event.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
type EventNames = keyof GlobalEventHandlersEventMap;
|
|
2
2
|
export declare function _on<T extends EventNames, H extends false | null | undefined | ((ev: GlobalEventHandlersEventMap[T], target: Element) => void)>(element: Element, type: T, handler: H): void;
|
|
3
|
-
export declare
|
|
3
|
+
export declare const delegate: (type: string, handler: EventListener) => any;
|
|
4
4
|
export {};
|