Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix for https://github.com/ibdknox/crate/issues/21 #22

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ pom.xml
*jar
/lib/
/classes/
.lein-deps-sum
.lein-deps-sum
/.idea/*
*.iml
6 changes: 4 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
(defproject crate "0.2.4"
:description "A ClojureScript implementation of Hiccup")
(defproject krate "0.2.5-SNAPSHOT"
:url "https://github.com/sonwh98/crate"
:description "A ClojureScript implementation of Hiccup. Fork of https://github.com/ibdknox/crate"
:license "Eclipse Public License")
10 changes: 7 additions & 3 deletions src/crate/compiler.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@
(do
(capture-binding :attr [k v])
(bind/value v))
v)]
(. elem (setAttribute (name k) v))))
v)
event (second (re-find #"^on(\w+)" (name k)))]
(if event
(. elem (addEventListener event v))
(. elem (setAttribute (name k) v)))))
elem))

;; From Weavejester's Hiccup: https://github.com/weavejester/hiccup/blob/master/src/hiccup/core.clj#L57
Expand Down Expand Up @@ -170,7 +173,8 @@
(defn elem-factory [tag-def]
(binding [bindings (atom [])]
(let [[nsp tag attrs content] (normalize-element tag-def)
elem (create-elem nsp tag)]
elem (create-elem nsp tag)
onclick (:onclick attrs)]
(dom-attr elem attrs)
(as-content elem content)
(handle-bindings @bindings elem)
Expand Down