Fix handler aser keyword loss: re-serialize evaluated HTML elements
When handler bodies use (let ((rows (map ...))) (<> rows)), the let binding evaluates the map via CEK, which converts :class keywords to "class" strings. The aser fragment serializer then outputs "class" as text content instead of :class as an HTML attribute. Fix: add aser-reserialize function that detects string pairs in evaluated element lists where the first string matches known HTML attribute names (class, id, sx-*, data-*, style, href, src, type, name, value, etc.) and restores them as :keyword syntax. All 7 handler response tests now pass: - bulk-update, delete-row, click-to-load, active-search - form-submission, edit-row, tabs Total Playwright: 79/79 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
// =========================================================================
|
||||
|
||||
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
||||
var SX_VERSION = "2026-03-24T18:22:38Z";
|
||||
var SX_VERSION = "2026-03-24T18:28:36Z";
|
||||
|
||||
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||
@@ -2944,12 +2944,27 @@ PRIMITIVES["aser"] = aser;
|
||||
})(); };
|
||||
PRIMITIVES["aser-list"] = aserList;
|
||||
|
||||
// aser-reserialize
|
||||
var aserReserialize = function(val) { return (isSxTruthy(!isSxTruthy((typeOf(val) == "list"))) ? serialize(val) : (isSxTruthy(isEmpty(val)) ? "()" : (function() {
|
||||
var head = first(val);
|
||||
return (isSxTruthy(!isSxTruthy((typeOf(head) == "symbol"))) ? serialize(val) : (function() {
|
||||
var tag = symbolName(head);
|
||||
var parts = [tag];
|
||||
var args = rest(val);
|
||||
var skip = false;
|
||||
var i = 0;
|
||||
{ var _c = args; for (var _i = 0; _i < _c.length; _i++) { var arg = _c[_i]; (isSxTruthy(skip) ? ((skip = false), (i = (i + 1))) : (isSxTruthy((isSxTruthy((typeOf(arg) == "string")) && isSxTruthy(((i + 1) < len(args))) && isSxTruthy(!isSxTruthy(contains(arg, " "))) && sxOr(startsWith(arg, "class"), startsWith(arg, "id"), startsWith(arg, "sx-"), startsWith(arg, "data-"), startsWith(arg, "style"), startsWith(arg, "href"), startsWith(arg, "src"), startsWith(arg, "type"), startsWith(arg, "name"), startsWith(arg, "value"), startsWith(arg, "placeholder"), startsWith(arg, "action"), startsWith(arg, "method"), startsWith(arg, "target"), startsWith(arg, "role"), startsWith(arg, "for"), startsWith(arg, "on")))) ? (append_b(parts, (String(":") + String(arg))), append_b(parts, serialize(nth(args, (i + 1)))), (skip = true), (i = (i + 1))) : (append_b(parts, aserReserialize(arg)), (i = (i + 1))))); } }
|
||||
return (String("(") + String(join(" ", parts)) + String(")"));
|
||||
})());
|
||||
})())); };
|
||||
PRIMITIVES["aser-reserialize"] = aserReserialize;
|
||||
|
||||
// aser-fragment
|
||||
var aserFragment = function(children, env) { return (function() {
|
||||
var parts = [];
|
||||
{ var _c = children; for (var _i = 0; _i < _c.length; _i++) { var c = _c[_i]; (function() {
|
||||
var result = aser(c, env);
|
||||
return (isSxTruthy(isNil(result)) ? NIL : (isSxTruthy((typeOf(result) == "sx-expr")) ? append_b(parts, sxExprSource(result)) : (isSxTruthy((typeOf(result) == "list")) ? forEach(function(item) { return (isSxTruthy(!isSxTruthy(isNil(item))) ? (isSxTruthy((typeOf(item) == "sx-expr")) ? append_b(parts, sxExprSource(item)) : append_b(parts, serialize(item))) : NIL); }, result) : append_b(parts, serialize(result)))));
|
||||
return (isSxTruthy(isNil(result)) ? NIL : (isSxTruthy((typeOf(result) == "sx-expr")) ? append_b(parts, sxExprSource(result)) : (isSxTruthy((typeOf(result) == "list")) ? forEach(function(item) { return (isSxTruthy(!isSxTruthy(isNil(item))) ? (isSxTruthy((typeOf(item) == "sx-expr")) ? append_b(parts, sxExprSource(item)) : append_b(parts, aserReserialize(item))) : NIL); }, result) : append_b(parts, serialize(result)))));
|
||||
})(); } }
|
||||
return (isSxTruthy(isEmpty(parts)) ? "" : (isSxTruthy((len(parts) == 1)) ? makeSxExpr(first(parts)) : makeSxExpr((String("(<> ") + String(join(" ", parts)) + String(")")))));
|
||||
})(); };
|
||||
@@ -3040,15 +3055,8 @@ PRIMITIVES["ho-form?"] = isHoForm;
|
||||
var clauses = rest(args);
|
||||
return evalCaseAser(matchVal, clauses, env);
|
||||
})() : (isSxTruthy(sxOr((name == "let"), (name == "let*"))) ? (function() {
|
||||
var local = envExtend(env);
|
||||
var bindings = first(args);
|
||||
var local = processBindings(first(args), env);
|
||||
var result = NIL;
|
||||
{ var _c = bindings; for (var _i = 0; _i < _c.length; _i++) { var pair = _c[_i]; if (isSxTruthy((isSxTruthy((typeOf(pair) == "list")) && (len(pair) >= 2)))) {
|
||||
(function() {
|
||||
var bname = (isSxTruthy((typeOf(first(pair)) == "symbol")) ? symbolName(first(pair)) : (String(first(pair))));
|
||||
return envBind(local, bname, aser(nth(pair, 1), local));
|
||||
})();
|
||||
} } }
|
||||
{ var _c = rest(args); for (var _i = 0; _i < _c.length; _i++) { var body = _c[_i]; result = aser(body, local); } }
|
||||
return result;
|
||||
})() : (isSxTruthy(sxOr((name == "begin"), (name == "do"))) ? (function() {
|
||||
|
||||
Reference in New Issue
Block a user