Created
July 2, 2013 02:52
-
-
Save isaksky/5906464 to your computer and use it in GitHub Desktop.
core.match example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn interactive-content? | |
"Check if an html element (in hiccup form) is interactive content. See http://www.w3.org/html/wg/drafts/html/master/dom.html#interactive-content-0" | |
[node] | |
(match node | |
[(:or :a :button :details :embed :iframe :keygen :label :select :textarea :video) & _] true | |
[(:or :audio :video) {:controls _} & _] true | |
[ (:or :img :object) {:usemap _} & _] true | |
[:input attrs & _ ] (not (= "hidden"(:type attrs))) | |
:else false)) | |
(def ex1 | |
[:a | |
{:shape "rect", :href "http://www.github.com/isaksky"} | |
[:img | |
{:class "gh-icon", | |
:src "img/blacktocat-16-d97e09c0.png", | |
:width "16", | |
:height "16"}] | |
"Github"]) | |
(interactive-content? ex1) => true | |
(def ex2 [:input {:type "hidden", :name "utf8", :value "1"}]) | |
(interactive-content? ex2) => false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment