Skip to content

Commit

Permalink
Merge pull request #43 from smee/pull-1
Browse files Browse the repository at this point in the history
Ignore links with `data-trigger` attribute: links that are actions
  • Loading branch information
David Jarvis authored Nov 1, 2017
2 parents 2b741e9 + f20c0fe commit 5572d20
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/accountant/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@
(let [token (.-token e)]
(nav-handler token)))))


(defn- find-href-node
"Given a DOM element that may or may not be a link, traverse up the DOM tree
to see if any of its parents are links. If so, return the node."
to see if any of its parents are links. If so, return the href content, if
it does not have an explicit `data-trigger` attribute to signify a non-navigational
link element."
[e]
(if (.-href e)
e
(when-let [parent (.-parentNode e)]
(recur parent))))
(let [href (.-href e)
attrs (.-attributes e)
navigation-link? (and href attrs (-> attrs (aget "data-trigger") not))]
(if navigation-link?
e
(when-let [parent (.-parentNode e)]
(recur parent)))))

(defn- uri->query [uri]
(let [query (.getQuery uri)]
Expand Down

0 comments on commit 5572d20

Please sign in to comment.