Merge worktree-typed into macros: defcomp type annotations
This commit is contained in:
@@ -1369,9 +1369,16 @@
|
||||
;; Inline lambda → for loop
|
||||
(let ((params (nth fn-expr 1))
|
||||
(body (rest (rest fn-expr)))
|
||||
(p (if (= (type-of (first params)) "symbol")
|
||||
(symbol-name (first params))
|
||||
(str (first params))))
|
||||
(raw-p (first params))
|
||||
(p (cond
|
||||
(= (type-of raw-p) "symbol")
|
||||
(symbol-name raw-p)
|
||||
;; (name :as type) annotation → extract name
|
||||
(and (= (type-of raw-p) "list") (= (len raw-p) 3)
|
||||
(= (type-of (nth raw-p 1)) "keyword")
|
||||
(= (keyword-name (nth raw-p 1)) "as"))
|
||||
(symbol-name (first raw-p))
|
||||
:else (str raw-p)))
|
||||
(p-js (js-mangle p)))
|
||||
(str "{ var _c = " coll "; for (var _i = 0; _i < _c.length; _i++) { var "
|
||||
p-js " = _c[_i]; "
|
||||
|
||||
@@ -1655,6 +1655,18 @@ PLATFORM_DOM_JS = """
|
||||
|
||||
function domGetProp(el, name) { return el ? el[name] : NIL; }
|
||||
function domSetProp(el, name, val) { if (el) el[name] = val; }
|
||||
// Call a method on an object with correct this binding: (dom-call-method obj "methodName" arg1 arg2 ...)
|
||||
function domCallMethod() {
|
||||
var obj = arguments[0], method = arguments[1];
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
console.log("[sx] dom-call-method:", obj, method, args);
|
||||
if (obj && typeof obj[method] === 'function') {
|
||||
try { return obj[method].apply(obj, args); }
|
||||
catch(e) { console.error("[sx] dom-call-method error:", e); return NIL; }
|
||||
}
|
||||
console.warn("[sx] dom-call-method: method not found or obj null", obj, method);
|
||||
return NIL;
|
||||
}
|
||||
|
||||
function domAddClass(el, cls) {
|
||||
if (el && el.classList) el.classList.add(cls);
|
||||
@@ -2872,6 +2884,8 @@ def fixups_js(has_html, has_sx, has_dom, has_signals=False, has_deps=False, has_
|
||||
PRIMITIVES["dom-focus"] = domFocus;
|
||||
PRIMITIVES["dom-tag-name"] = domTagName;
|
||||
PRIMITIVES["dom-get-prop"] = domGetProp;
|
||||
PRIMITIVES["dom-set-prop"] = domSetProp;
|
||||
PRIMITIVES["dom-call-method"] = domCallMethod;
|
||||
PRIMITIVES["stop-propagation"] = stopPropagation_;
|
||||
PRIMITIVES["error-message"] = errorMessage;
|
||||
PRIMITIVES["schedule-idle"] = scheduleIdle;
|
||||
|
||||
Reference in New Issue
Block a user