Skip to content

Commit

Permalink
Merge pull request #1 from onionpancakes/fix/shadow-attrs-core-fns
Browse files Browse the repository at this point in the history
Fixed shadowing attrs core fns
  • Loading branch information
onionpancakes authored Feb 25, 2024
2 parents 84f9abc + 4de7888 commit 161cde2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/dev/onionpancakes/chassis/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@
#'clojure.core/update-vals})

(defn attrs-invocation?
[[sym & _]]
(and (symbol? sym)
(contains? attrs-invocable-vars (resolve sym))))
[[sym & _ :as this]]
(and (seq? this)
(symbol? sym)
(bound? #'*env*)
(contains? attrs-invocable-vars (resolve *env* sym))))

(defn attrs-type?
[clazz]
Expand Down
8 changes: 8 additions & 0 deletions test/dev/onionpancakes/chassis/tests/test_compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@
(doseq [[elem warning] @ambig-attrs-warnings]
(is false (str "Ambig attrs with elem: " elem))))

(deftest test-compile-shadow-attrs-core-fns
(let [assoc (fn [& _] "assoc-shadowed")
merge (fn [& _] "merge-shadowed")]
(is (= (c/html (cc/compile [:div (assoc {} :foo :bar)]))
"<div>assoc-shadowed</div>"))
(is (= (c/html (cc/compile [:div (merge {} {:foo :bar})]))
"<div>merge-shadowed</div>"))))

;; Alias

(defmethod c/resolve-alias ::TestAliasContent
Expand Down

0 comments on commit 161cde2

Please sign in to comment.