Skip to content

Commit

Permalink
Click event sets token with query string
Browse files Browse the repository at this point in the history
  • Loading branch information
wavejumper committed Jul 17, 2015
1 parent d764e79 commit dc651cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject kibu/pushy "0.3.1"
(defproject kibu/pushy "0.3.2"
:description "HTML5 pushState for Clojurescript"
:url "https://github.com/kibu-australia/pushy"
:license {:name "Eclipse Public License"
Expand Down
13 changes: 8 additions & 5 deletions src/pushy/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@
(on-click
(fn [e]
(when-let [el (recur-href (-> e .-target))]
(let [href (.-href el)
path (->> href (.parse Uri) .getPath)]
(let [uri (.parse Uri (.-href el))
path (.getPath uri)
query (.getQuery uri)
;; Include query string in token
next-token (if (empty? query) path (str path "?" query))]
;; Proceed if `identity-fn` returns a value and
;; the user did not trigger the event via one of the
;; keys we should bypass
(when (and (identity-fn (match-fn path))
(when (and (identity-fn (match-fn next-token))
;; Bypass dispatch if any of these keys
(not (.-altKey e))
(not (.-ctrlKey e))
Expand All @@ -107,8 +110,8 @@
(not= 1 (.-button e)))
;; Dispatch!
(if-let [title (-> el .-title)]
(set-token! this path title)
(set-token! this path))
(set-token! this next-token title)
(set-token! this next-token))
(.preventDefault e)))))))
nil)

Expand Down

0 comments on commit dc651cd

Please sign in to comment.