Skip to content

Commit

Permalink
Fix #592: fix clj->js for custom classes (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored Dec 3, 2024
1 parent bfe1ab5 commit 4358aa2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "squint-cljs",
"type": "module",
"sideEffects": false,
"version": "0.8.127",
"version": "0.8.128",
"files": [
"core.js",
"src/squint/core.js",
Expand Down
3 changes: 2 additions & 1 deletion src/squint/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2751,7 +2751,8 @@ function clj__GT_js_(x, seen) {
return update_vals(x, x => clj__GT_js_(x, seen));
}

if (coll_QMARK_(x)) {
const tc = typeConst(x);
if (tc && tc != OBJECT_TYPE) {
return mapv(x => clj__GT_js_(x, seen), x);
}
return x;
Expand Down
6 changes: 5 additions & 1 deletion test/squint/compiler_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2339,7 +2339,11 @@ new Foo();")
(is (eq {:a [2 3 4]}
(jsv! "(clj->js {:a (map inc [1 2 3])})")))
(is (eq [2 3 4]
(jsv! "(def x {:a 1 :b (map inc [1 2 3])}) (set! (.-a x) x) (:b (clj->js x))"))))
(jsv! "(def x {:a 1 :b (map inc [1 2 3])}) (set! (.-a x) x) (:b (clj->js x))")))
(is (true?
(jsv! "(defclass Foo (constructor [this x] (set! this.x x))) (instance? Foo (clj->js (new Foo [1 2 3])))")))
(is (true?
(jsv! "(= \"foo\" (clj->js \"foo\"))"))))

(defn init []
(t/run-tests 'squint.compiler-test 'squint.jsx-test 'squint.string-test 'squint.html-test))

0 comments on commit 4358aa2

Please sign in to comment.