diff --git a/examples/frontend/src/frontend/core.cljs b/examples/frontend/src/frontend/core.cljs index 548e8a2a..fcd720f5 100644 --- a/examples/frontend/src/frontend/core.cljs +++ b/examples/frontend/src/frontend/core.cljs @@ -27,7 +27,13 @@ [:ul [:li [:a {:href "http://google.com"} "external link"]] [:li [:a {:href (rfe/href ::foobar)} "Missing route"]] - [:li [:a {:href (rfe/href ::item)} "Missing route params"]]]]) + [:li [:a {:href (rfe/href ::item)} "Missing route params"]]] + + [:div + {:content-editable true + :suppressContentEditableWarning true} + [:p "Link inside contentEditable element is ignored."] + [:a {:href (rfe/href ::frontpage)} "Link"]]]) (defn item-page [match] (let [{:keys [path query]} (:parameters match) diff --git a/modules/reitit-frontend/src/reitit/frontend/history.cljs b/modules/reitit-frontend/src/reitit/frontend/history.cljs index 97be00c6..08affd0f 100644 --- a/modules/reitit-frontend/src/reitit/frontend/history.cljs +++ b/modules/reitit-frontend/src/reitit/frontend/history.cljs @@ -4,8 +4,7 @@ (:require [reitit.core :as reitit] [reitit.core :as r] [reitit.frontend :as rf] - [goog.events :as gevents] - [goog.dom :as gdom]) + [goog.events :as gevents]) (:import goog.Uri)) (defprotocol History @@ -78,8 +77,10 @@ (not (contains? #{"_blank" "self"} (.getAttribute el "target"))) ;; Left button (= 0 (.-button e)) - (reitit/match-by-path router (.getPath uri)) - (not (gdom/getAncestor el (fn [node] (.isContentEditable node))))) + ;; isContentEditable property is inherited from parents, + ;; so if the anchor is inside contenteditable div, the property will be true. + (not (.-isContentEditable (.-target e))) + (reitit/match-by-path router (.getPath uri))) (.preventDefault e) (let [path (str (.getPath uri) (if (seq (.getQuery uri))