From bb8a40c1dfc0c4d8fb66b01a820a308f31b8ac3f Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:12:55 +0100 Subject: [PATCH 01/52] move macros.clj to src/clj --- src/{cljs => clj}/domina/macros.clj | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{cljs => clj}/domina/macros.clj (100%) diff --git a/src/cljs/domina/macros.clj b/src/clj/domina/macros.clj similarity index 100% rename from src/cljs/domina/macros.clj rename to src/clj/domina/macros.clj From 811985fbff92d3d5e3ed9f1e69abb26969b3ec5a Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:14:29 +0100 Subject: [PATCH 02/52] upgrade clj to 1.5.1, cljs to 0.0-1847, cljsbuild to 0.3.2, remove unused stuff --- project.clj | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/project.clj b/project.clj index a2d954c..c385ae6 100644 --- a/project.clj +++ b/project.clj @@ -1,12 +1,11 @@ (defproject domina "1.0.3-SNAPSHOT" :description "A DOM manipulation library for ClojureScript inspired by JQuery" - :source-paths ["src/cljs"] - :dependencies [[org.clojure/clojure "1.4.0"]] - :plugins [[lein-cljsbuild "0.3.0"] - [lein-clojars "0.9.1"]] + :source-paths ["src/clj" "src/cljs"] + :dependencies [[org.clojure/clojure "1.5.1"] + [org.clojure/clojurescript "0.0-1847"]] + :plugins [[lein-cljsbuild "0.3.2"]] :hooks [leiningen.cljsbuild] - :cljsbuild {:builds [{:jar true - :compiler {:libs ["goog/dom/query.js"] + :cljsbuild {:builds [{:compiler {:libs ["goog/dom/query.js"] :pretty-print true :output-dir ".cljsbuild/domina" :output-to "public/domina.js"}} @@ -33,15 +32,4 @@ :optimizations :advanced :pretty-print true :output-dir ".cljsbuild/advanced" - :output-to "public/test_advanced.js"}}]} - :repositories {"sonatype-staging" - "https://oss.sonatype.org/content/groups/staging/"}) - -(comment - (do - (require '[cljs.repl :as repl]) - (require '[cljs.repl.browser :as browser]) - (def env (browser/repl-env)) - (repl/repl env)) - - ) + :output-to "public/test_advanced.js"}}]}) From 0ebd401fc30b24e0c075da874606475ad59c911b Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:19:57 +0100 Subject: [PATCH 03/52] remove blank line from the topo --- src/cljs/domina/events.cljs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cljs/domina/events.cljs b/src/cljs/domina/events.cljs index 1db48f3..9dee1ef 100644 --- a/src/cljs/domina/events.cljs +++ b/src/cljs/domina/events.cljs @@ -1,4 +1,3 @@ - (ns domina.events (:require [domina :as domina] [goog.object :as gobj] From 6f96219f5d920970789c62ba7280183511493ec8 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:22:44 +0100 Subject: [PATCH 04/52] remove not existent dispatch-event fn --- test/cljs/domina/test.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cljs/domina/test.cljs b/test/cljs/domina/test.cljs index 0ebe5e1..fd0b136 100644 --- a/test/cljs/domina/test.cljs +++ b/test/cljs/domina/test.cljs @@ -12,7 +12,7 @@ [domina.xpath :only [xpath]] [domina.css :only [sel]] [domina.events :only [listen! capture! listen-once! capture-once! - unlisten! dispatch-event! dispatch! unlisten-by-key! + unlisten! dispatch! unlisten-by-key! get-listeners prevent-default stop-propagation target current-target event-type raw-event]]) (:require [goog.events :as events] From d801e9bb30d339b5810f4527271d7b93b7777062 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:36:01 +0100 Subject: [PATCH 05/52] add clojurescript.test and move testing stuff into the dev profile --- project.clj | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/project.clj b/project.clj index c385ae6..e1cc2c0 100644 --- a/project.clj +++ b/project.clj @@ -8,28 +8,29 @@ :cljsbuild {:builds [{:compiler {:libs ["goog/dom/query.js"] :pretty-print true :output-dir ".cljsbuild/domina" - :output-to "public/domina.js"}} - {:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :pretty-print true - :optimizations :none - :output-dir "public/build_no_opt" - :output-to "public/test_no_opt.js"}} - {:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :optimizations :whitespace - :pretty-print true - :output-dir ".cljsbuild/whitespace" - :output-to "public/test_whitespace.js"}} - {:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :optimizations :simple - :pretty-print true - :output-dir ".cljsbuild/simple" - :output-to "public/test_simple.js"}} - {:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :optimizations :advanced - :pretty-print true - :output-dir ".cljsbuild/advanced" - :output-to "public/test_advanced.js"}}]}) + :output-to "public/domina.js"}}]} + :profiles {:dev {:plugins [[com.cemerick/clojurescript.test "0.1.0"]] + :cljsbuild {:builds [{:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :pretty-print true + :optimizations :none + :output-dir "public/build_no_opt" + :output-to "public/test_no_opt.js"}} + {:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :optimizations :whitespace + :pretty-print true + :output-dir ".cljsbuild/whitespace" + :output-to "public/test_whitespace.js"}} + {:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :optimizations :simple + :pretty-print true + :output-dir ".cljsbuild/simple" + :output-to "public/test_simple.js"}} + {:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :optimizations :advanced + :pretty-print true + :output-dir ".cljsbuild/advanced" + :output-to "public/test_advanced.js"}}]}}}) From 864e290849b74ce4f91e528ae4fbd9f87173f269 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:46:27 +0100 Subject: [PATCH 06/52] remove dev profile --- project.clj | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/project.clj b/project.clj index e1cc2c0..3396658 100644 --- a/project.clj +++ b/project.clj @@ -8,29 +8,4 @@ :cljsbuild {:builds [{:compiler {:libs ["goog/dom/query.js"] :pretty-print true :output-dir ".cljsbuild/domina" - :output-to "public/domina.js"}}]} - :profiles {:dev {:plugins [[com.cemerick/clojurescript.test "0.1.0"]] - :cljsbuild {:builds [{:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :pretty-print true - :optimizations :none - :output-dir "public/build_no_opt" - :output-to "public/test_no_opt.js"}} - {:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :optimizations :whitespace - :pretty-print true - :output-dir ".cljsbuild/whitespace" - :output-to "public/test_whitespace.js"}} - {:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :optimizations :simple - :pretty-print true - :output-dir ".cljsbuild/simple" - :output-to "public/test_simple.js"}} - {:source-paths ["test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :optimizations :advanced - :pretty-print true - :output-dir ".cljsbuild/advanced" - :output-to "public/test_advanced.js"}}]}}}) + :output-to "public/domina.js"}}]}) From bf2c1fc178029b9ff13a91072beb58ad0a8c4afc Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:46:48 +0100 Subject: [PATCH 07/52] add dev profile --- profiles.clj | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 profiles.clj diff --git a/profiles.clj b/profiles.clj new file mode 100644 index 0000000..067356f --- /dev/null +++ b/profiles.clj @@ -0,0 +1,26 @@ +{:dev {:test-paths ["test/cljs"] + :plugins [[com.cemerick/clojurescript.test "0.1.0"]] + :cljsbuild {:builds [{:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :pretty-print true + :optimizations :none + :output-dir "public/build_no_opt" + :output-to "public/test_no_opt.js"}} + {:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :optimizations :whitespace + :pretty-print true + :output-dir ".cljsbuild/whitespace" + :output-to "public/test_whitespace.js"}} + {:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :optimizations :simple + :pretty-print true + :output-dir ".cljsbuild/simple" + :output-to "public/test_simple.js"}} + {:source-paths ["test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :optimizations :advanced + :pretty-print true + :output-dir ".cljsbuild/advanced" + :output-to "public/test_advanced.js"}}]}}} From ce4cad79a8c032a04c65667936050ba26d0d9e9f Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 11:51:34 +0100 Subject: [PATCH 08/52] move test to temp --- {test => temp/test}/cljs/domina/test.cljs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {test => temp/test}/cljs/domina/test.cljs (100%) diff --git a/test/cljs/domina/test.cljs b/temp/test/cljs/domina/test.cljs similarity index 100% rename from test/cljs/domina/test.cljs rename to temp/test/cljs/domina/test.cljs From f31cd0752247c230b9aeea470ecf15ed5badc394 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 12:24:01 +0100 Subject: [PATCH 09/52] move from vector to map, added :source-paths --- project.clj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/project.clj b/project.clj index 3396658..95b1f71 100644 --- a/project.clj +++ b/project.clj @@ -5,7 +5,9 @@ [org.clojure/clojurescript "0.0-1847"]] :plugins [[lein-cljsbuild "0.3.2"]] :hooks [leiningen.cljsbuild] - :cljsbuild {:builds [{:compiler {:libs ["goog/dom/query.js"] + :cljsbuild {:builds {:deploy + {:source-paths ["src/cljs"] + :compiler {:libs ["goog/dom/query.js"] :pretty-print true :output-dir ".cljsbuild/domina" - :output-to "public/domina.js"}}]}) + :output-to "public/domina.js"}}}}) From 771a14901443bc57f360f2621b49e06c2e3b33bd Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 12:24:37 +0100 Subject: [PATCH 10/52] name builds --- profiles.clj | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/profiles.clj b/profiles.clj index 067356f..9136653 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,26 +1,30 @@ {:dev {:test-paths ["test/cljs"] :plugins [[com.cemerick/clojurescript.test "0.1.0"]] - :cljsbuild {:builds [{:source-paths ["test/cljs"] + :cljsbuild {:builds {:none + {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :pretty-print true :optimizations :none :output-dir "public/build_no_opt" :output-to "public/test_no_opt.js"}} - {:source-paths ["test/cljs"] + :whitespace + {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :whitespace :pretty-print true :output-dir ".cljsbuild/whitespace" :output-to "public/test_whitespace.js"}} - {:source-paths ["test/cljs"] + :simple + {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :simple :pretty-print true :output-dir ".cljsbuild/simple" :output-to "public/test_simple.js"}} - {:source-paths ["test/cljs"] + :advanced + {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :advanced :pretty-print true :output-dir ".cljsbuild/advanced" - :output-to "public/test_advanced.js"}}]}}} + :output-to "public/test_advanced.js"}}}}}} From 1707a23ac298a4c8a8af3f64d3fb981df82beca3 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 20:10:16 +0100 Subject: [PATCH 11/52] add test-commands, dev-resources, remove :ouput-dir and modify :output-to --- profiles.clj | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/profiles.clj b/profiles.clj index 9136653..620f335 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,30 +1,35 @@ {:dev {:test-paths ["test/cljs"] + :dependencies [[hiccups "0.2.0"]] :plugins [[com.cemerick/clojurescript.test "0.1.0"]] :cljsbuild {:builds {:none {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :pretty-print true :optimizations :none - :output-dir "public/build_no_opt" - :output-to "public/test_no_opt.js"}} + :output-to "dev-resources/public/js/none.js"}} :whitespace {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :whitespace :pretty-print true - :output-dir ".cljsbuild/whitespace" - :output-to "public/test_whitespace.js"}} + :output-to "dev-resources/public/js/whitespace.js"}} :simple {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :simple :pretty-print true - :output-dir ".cljsbuild/simple" - :output-to "public/test_simple.js"}} + :output-to "dev-resources/public/js/simple.js"}} :advanced {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :advanced :pretty-print true - :output-dir ".cljsbuild/advanced" - :output-to "public/test_advanced.js"}}}}}} + :output-to "dev-resources/public/js/advanced.js"}}} + :test-commands {"whitespace" + ["phantomjs" :runner "dev-resources/public/js/whitespace.js"] + + "simple" + ["phantomjs" :runner "dev-resources/public/js/simple.js"] + + "advanced" + ["phantomjs" :runner "dev-resources/public/js/advanced.js"]}}}} From 93cce00bf08118d571b80584ab74582e542b335e Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 20:11:08 +0100 Subject: [PATCH 12/52] comment test implemented with clojurescript.test --- temp/test/cljs/domina/test.cljs | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/temp/test/cljs/domina/test.cljs b/temp/test/cljs/domina/test.cljs index fd0b136..f158747 100644 --- a/temp/test/cljs/domina/test.cljs +++ b/temp/test/cljs/domina/test.cljs @@ -101,10 +101,10 @@ ;;;;;; DOM Manipulation Tests -(add-test "basic xpath selection" - #(do (reset) - (standard-fixture) - (assert (= 3 (count (nodes (xpath "//p"))))))) +add-test "basic xpath selection" +#(do (reset) + (standard-fixture) + (assert (= 3 (count (nodes (xpath "//p")))))) (add-test "basic xpath selection (single node)" #(do (reset) @@ -135,7 +135,7 @@ (standard-fixture) (assert (= 2 (count (nodes (xpath "//p[following-sibling::p[@class='p3']]"))))))) -(add-test "look up node by id" +#_(add-test "look up node by id" #(do (reset) (standard-fixture) (assert (= 1 (count (nodes (by-id "id1"))))))) @@ -149,51 +149,51 @@ (sel "p") (sel "span")))))))) -(add-test "look up nodes by class" +#_(add-test "look up nodes by class" #(do (reset) (standard-fixture) (assert (= 1 (count (nodes (by-class "p3"))))))) -(add-test "look up multiple nodes by class" +#_(add-test "look up multiple nodes by class" #(do (reset) (append! (xpath "//body") "

test1

test2

") (assert (= 2 (count (nodes (by-class "tc"))))))) -(add-test "child selection" +#_(add-test "child selection" #(do (reset) (standard-fixture) (assert (= 3 (count (children (xpath "//div[@class='d1']"))))))) -(add-test "clone a single node" +#_(add-test "clone a single node" #(do (reset) (standard-fixture) (assert (= 1 (count (clone (single-node (xpath "//p")))))))) -(add-test "clone multiple nodes" +#_(add-test "clone multiple nodes" #(do (reset) (standard-fixture) (assert (= 3 (count (clone (nodes (xpath "//p")))))))) -(add-test "append a single child to a single parent" +#_(add-test "append a single child to a single parent" #(do (reset) (append! (xpath "//body") "

test

") (assert (= 1 (count (nodes (xpath "//body/p[@class='appended1']"))))))) -(add-test "append multiple children to a single parent" +#_(add-test "append multiple children to a single parent" #(do (reset) (append! (xpath "//body") "

test2-1

test2-2

") (assert (= 2 (count (nodes (xpath "//body/p[@class='appended2']"))))))) -(add-test "append a single child to multiple parents" +#_(add-test "append a single child to multiple parents" #(do (reset) (standard-fixture) (append! (xpath "//body/div/p") "!!") (assert (= 3 (count (nodes (xpath "//div/p/span"))))))) -(add-test "append multiple children to multiple parents" +#_(add-test "append multiple children to multiple parents" #(do (reset) (standard-fixture) (append! (xpath "//body/div/p") @@ -248,14 +248,14 @@ (assert (= 1 (count (nodes (xpath children "p[@class='i2']/following-sibling::*")))))))) -(add-test "destroy a single node" +#_(add-test "destroy a single node" #(do (reset) (append! (xpath "//body") "

app1

") (assert (= 1 (count (nodes (xpath "//body/p[@class='appended1']"))))) (destroy! (xpath "//body/p[@class='appended1']")) (assert (= 0 (count (nodes (xpath "//body/p[@class='appended1']"))))))) -(add-test "destroy multiple nodes" +#_(add-test "destroy multiple nodes" #(do (reset) (append! (xpath "//body") "

app1

app2

") @@ -263,7 +263,7 @@ (destroy! (xpath "//body/p[@class='appended2']")) (assert (= 0 (count (nodes (xpath "//body/p[@class='appended2']"))))))) -(add-test "detach and reattach a single node" +#_(add-test "detach and reattach a single node" #(do (reset) (standard-fixture) (let [n (detach! (xpath "//p[@class='p3']"))] @@ -271,7 +271,7 @@ (append! (xpath "//div[@class='d1']") n) (assert (= 1 (count (nodes (xpath "//p[@class='p3']")))))))) -(add-test "detach and reattach multiple nodes" +#_(add-test "detach and reattach multiple nodes" #(do (reset) (standard-fixture) (let [n (detach! (xpath "//div[@class='d1']/p"))] @@ -279,7 +279,7 @@ (append! (xpath "//div[@class='d1']") n) (assert (= 3 (count (nodes (xpath "//div[@class='d1']/p")))))))) -(add-test "detach child nodes" +#_(add-test "detach child nodes" #(do (reset) (standard-fixture) (let [parent (xpath "//div[@class='d1']") @@ -287,27 +287,27 @@ (assert (= 0 (count (nodes (xpath "//div[@class='d1']/p"))))) (assert (= 3 (count detached-children)))))) -(add-test "clear a node's contents" +#_(add-test "clear a node's contents" #(do (reset) (standard-fixture) (destroy-children! (xpath "//div[@class='d1']")) (assert (= 1 (count (nodes (xpath "//div[@class='d1']"))))) (assert (= 0 (count (nodes (xpath "//div[@class='d1']/*"))))))) -(add-test "insert-before! with a single reference and single new node" +#_(add-test "insert-before! with a single reference and single new node" #(do (reset) (append! (xpath "//body") "
Some content
") (insert-before! (nodes (by-id "ref")) "

before

") (assert (= 1 (count (nodes (xpath "//div[@id='ref']/preceding-sibling::*[text()='before']"))))))) -(add-test "insert-before! with a single reference and multiple new nodes" +#_(add-test "insert-before! with a single reference and multiple new nodes" #(do (reset) (append! (xpath "//body") "
Some content
") (insert-before! (nodes (by-id "ref")) "

before1

before2

") (assert (= 1 (count (nodes (xpath "//div[@id='ref']/preceding-sibling::*[text()='before2' and position()=1]"))))) (assert (= 1 (count (nodes (xpath "//div[@id='ref']/preceding-sibling::*[text()='before1' and position()=2]"))))))) -(add-test "insert-before! with multiple reference nodes and a single new node" +#_(add-test "insert-before! with multiple reference nodes and a single new node" #(do (reset) (append! (xpath "//body") "
content1
") (append! (xpath "//body") "
content2
") From c13555d3f8641027490e84f3bc2457c72be5cc5f Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 20:12:49 +0100 Subject: [PATCH 13/52] add unit tests --- test/cljs/domina/css_standard_test.cljs | 31 +++ test/cljs/domina/fixtures.cljs | 22 ++ test/cljs/domina/xpath_standard_test.cljs | 31 +++ test/cljs/domina_edge_test.cljs | 247 ++++++++++++++++++++++ test/cljs/domina_standard_test.cljs | 193 +++++++++++++++++ 5 files changed, 524 insertions(+) create mode 100644 test/cljs/domina/css_standard_test.cljs create mode 100644 test/cljs/domina/fixtures.cljs create mode 100644 test/cljs/domina/xpath_standard_test.cljs create mode 100644 test/cljs/domina_edge_test.cljs create mode 100644 test/cljs/domina_standard_test.cljs diff --git a/test/cljs/domina/css_standard_test.cljs b/test/cljs/domina/css_standard_test.cljs new file mode 100644 index 0000000..acec944 --- /dev/null +++ b/test/cljs/domina/css_standard_test.cljs @@ -0,0 +1,31 @@ +(ns domina.css-standard-test + (:require-macros [cemerick.cljs.test :as m :refer (deftest testing are use-fixtures)] + [domina.macros :as dm] + [hiccups.core :as hm]) + (:require [cemerick.cljs.test :as t] + [domina :as dom :refer (nodes append!)] + [domina.css :as css :refer (sel)] + [domina.fixtures :as fix :refer (base-fixture)] + [hiccups.runtime :as hrt])) + +(use-fixtures :each base-fixture) + +;;; sel +(deftest sel-test + (testing "Unit Testing for (sel css-expr)\n" + (testing "Standard Cases\n" + (are [expected actual] (= expected actual) + 3 (count (nodes (sel "p"))) + 1 (count (nodes (sel ".d1"))) + 1 (count (nodes (sel "#id1"))) + 3 (count (nodes (-> (sel ".d1") + (sel "p")))) + 3 (count (nodes (sel ".d1 > p"))) + 2 (do (append! (sel "body") + (hm/html [:div + [:p [:span "some text"]] + [:p [:span "more text"]]])) + (count (nodes (-> (sel "body") + (sel "div") + (sel "p") + (sel "span"))))))))) diff --git a/test/cljs/domina/fixtures.cljs b/test/cljs/domina/fixtures.cljs new file mode 100644 index 0000000..e420691 --- /dev/null +++ b/test/cljs/domina/fixtures.cljs @@ -0,0 +1,22 @@ +(ns domina.fixtures + (:require-macros [domina.macros :as dm] + [hiccups.core :as hm]) + (:require [domina :as dom :refer (append! destroy!)] + [hiccups.runtime :as hrt] + [domina.xpath :as css :refer (xpath)] + [domina.events :as de :refer (unlisten!)])) + +(defn- initialize [] + (append! (xpath "//body") + (hm/html [:div.d1 + [:p.p1 "P1"] + [:p.p2 "P2"] + [:p#id1.p3 "P3"]]))) +(defn- reset[] + (destroy! (xpath "//body/*")) + (unlisten! (xpath "//*"))) + +(defn base-fixture [f] + (initialize) + (f) + (reset)) diff --git a/test/cljs/domina/xpath_standard_test.cljs b/test/cljs/domina/xpath_standard_test.cljs new file mode 100644 index 0000000..fbae33f --- /dev/null +++ b/test/cljs/domina/xpath_standard_test.cljs @@ -0,0 +1,31 @@ +(ns domina.xpath-standard-test + (:require-macros [cemerick.cljs.test :as m :refer (deftest testing are use-fixtures)] + [domina.macros :as dm] + [hiccups.core :as hm]) + (:require [cemerick.cljs.test :as t] + [domina :as dom :refer (nodes single-node append!)] + [domina.xpath :as css :refer (xpath)] + [domina.fixtures :as fix :refer (base-fixture)] + [hiccups.runtime :as hrt])) + +(use-fixtures :each base-fixture) + +;;; xpath +(deftest xpath-test + (testing "Unit Testing for (xpath xpath-expr)\n" + (testing "Standard Cases\n" + (are [expected actual] (= expected actual) + 3 (count (nodes (xpath "//p"))) + false (nil? (single-node (xpath "//p"))) + 1 (count (nodes (xpath "//div[@class='d1']"))) + 3 (count (nodes (-> (xpath "//body/div[@class='d1']") + (xpath "p")))) + 2 (do + (append! (xpath "//body") + (hm/html [:div + [:p [:span "some text"]] + [:p [:span "more text"]]])) + (count (nodes (-> (xpath "//body") + (xpath "./div") + (xpath "./p") + (xpath "./span"))))))))) diff --git a/test/cljs/domina_edge_test.cljs b/test/cljs/domina_edge_test.cljs new file mode 100644 index 0000000..c866a14 --- /dev/null +++ b/test/cljs/domina_edge_test.cljs @@ -0,0 +1,247 @@ +(ns domina-edge-test + (:require-macros [cemerick.cljs.test :as m :refer (deftest testing are use-fixtures)] + [domina.macros :as dm]) + (:require [cemerick.cljs.test :as t] + [domina :as dom :refer (nodes + single-node + by-class + by-id + append! + prepend! + clone + ancestor? + common-ancestor + children + detach! + destroy! + destroy-children! + has-class? + value)] + [domina.xpath :as xp :refer (xpath)] + [domina.fixtures :as fix :refer (base-fixture)])) + +(use-fixtures :each base-fixture) + +;;; nodes +(deftest nodes-test + (testing "Unit Testing for (nodes content)\n" + (testing "Edge Cases\n" + (testing "(nodes content)" + (are [expected actual] (= expected actual) + () (nodes nil) + false (nil? (nodes "")) + false (nil? (nodes " ")) + false (nil? (nodes (by-id "not-an-existent-id"))) + nil (nodes ()) + nil (nodes []) + nil (nodes {}) + nil (nodes #{})))))) + +;;; single-node +(deftest single-node-test + (testing "Unit Testing for (single-node node)\n" + (testing "Edge Cases\n" + (testing "(single-node node)" + (are [expected actual] (= expected actual) + nil (single-node nil) + false (nil? (single-node "")) + false (nil? (single-node " ")) + true (nil? (single-node (by-class "not-a-class"))) + true (nil? (single-node (by-id "not-an-id"))) + nil (single-node ()) + nil (single-node []) + nil (single-node {}) + nil (single-node #{})))))) + +;;; by-id +(deftest by-id-test + (testing "Unit Testing for (by-id id)\n" + (testing "Edge Cases\n" + (testing "(by-id s)" + (are [expected actual] (= expected actual) + "Error" (try + (by-id nil) + (catch js/Error e + "Error")) + nil (by-id "") + nil (by-id "not-existent-id") + nil (by-id " ")))))) + +;;; by-class +(deftest by-class-test + (testing "Unit Testing for (by-class css-class)\n" + (testing "Edge Cases\n" + (testing "(by-class css-class)" + (are [expected actual] (= expected actual) + "Error" (try + (by-class nil) + (catch js/Error e + "Error")) + ;nil (by-class "") + ;nil (by-class " ") + nil (by-class "not-existent-class")))))) + +;;; append! +(deftest append!-test + (testing "Unit Testing for (append! parent-content child-content)\n" + (testing "Edge Cases\n" + (testing "(append! single-parent single-child)" + (are [expected actual] (= expected actual) + nil (append! nil nil) + () (children (append! (by-id "id1") nil)) + () (children (append! (by-id "id1") "")) + () (children (append! (by-id "id1") " ")) + nil (append! nil "
"))) + (testing "(append! multiple-parent child-content)" + (are [expected actual] (= expected actual) + () (children (append! (by-class "p1") nil)) + () (children (append! (by-class "p1") "")) + () (children (append! (by-class "p1") " ")) + () (children (append! (by-class "p1") ())) + () (children (append! (by-class "p1") [])) + () (children (append! (by-class "p1") {})) + () (children (append! (by-class "p1") #{}))))))) + +;;; detach +(deftest detach!-test + (testing "Unit Testing for (detach! content)\n" + (testing "Edge Cases\n" + (testing "(detach! content)" + (are [expected actual] (= expected actual) + () (detach! nil) + '(nil) (detach! "") + '(nil) (detach! " ") + () (detach! ()) + () (detach! []) + () (detach! {}) + () (detach! #{}) + () (detach! (by-class "not-a-class")) + () (detach! (by-id "not-an-id"))))))) + +;;; children +(deftest children-test + (testing "Unit Testing for (children content)\n" + (testing "Edge Cases\n" + (testing "(children content)" + (are [expected actual] (= expected actual) + () (children nil) + () (children "") + () (children " ") + () (children ()) + () (children []) + () (children {}) + () (children #{}) + () (children "not-existent-parent") + () (children "not existent parent")))))) + +;;; destroy +(deftest destroy!-test + (testing "Unit Testing for (destroy! content)\n" + (testing "Edge Cases\n" + (testing "(destroy! content)" + (are [expected actual] (= expected actual) + nil (destroy! nil) + nil (destroy! "") + nil (destroy! " ") + nil (destroy! "not-a-content") + nil (destroy! "not a content") + nil (destroy! ()) + nil (destroy! []) + nil (destroy! {}) + nil (destroy! #{})))))) + +;;; common-ancestor +(deftest common-ancestor-test + (testing "Unit Testing for (common-ancestor &contents)\n" + (testing "Edge Cases\n" + (testing "(common-ancestor node-a)" + (are [expected actual] (= expected actual) + nil (common-ancestor nil))) + (testing "(common-ancestor node-a node-b)" + (are [expected actual] (= expected actual) + nil (common-ancestor nil nil) + nil (common-ancestor nil (by-id "id1")) + nil (common-ancestor (by-id "id1") nil))) + (testing "(common-ancestor node-a node-b node-c)" + (are [expected actual] (= expected actual) + nil (common-ancestor nil nil nil) + nil (common-ancestor nil (by-id "id1") nil) + nil (common-ancestor nil nil (by-id "id1")) + nil (common-ancestor (by-id "id1") nil nil)))))) + +;;; ancestor? +(deftest ancestor?-test + (testing "Unit Testing for (ancestor? ancestor-node descendant-node)\n" + (testing "Edge Cases\n" + (testing "(ancestor? ancestor descendant)" + (are [expected actual] (= expected actual) + true (ancestor? nil nil) + true (ancestor? nil (by-id "id1")) + false (ancestor? (by-id "id1") nil) + + true (ancestor? () ()) + true (ancestor? nil ()) + true (ancestor? () nil) + + true (ancestor? [] []) + true (ancestor? nil []) + true (ancestor? [] nil) + + true (ancestor? {} {}) + true (ancestor? nil {}) + true (ancestor? {} nil) + + true (ancestor? #{} #{}) + true (ancestor? nil #{}) + true (ancestor? #{} nil)))))) + +;;; clone +(deftest clone-test + (testing "Unit Testing for (clone node)\n" + (testing "Edge Cases\n" + (testing "(clone node)" + (are [expected actual] (= expected actual) + () (clone nil) + () (clone ()) + () (clone []) + () (clone {}) + () (clone #{})))))) + +;;; has-class? +(deftest has-class?-test + (testing "Unit Testing for (has-class? content class)\n" + (testing "Edge Cases\n" + (testing "(has-class? content class)" + (are [expected actual] (= expected actual) + "Error" (try + (has-class? nil nil) + (catch js/Error e + "Error")) + "Error" (try + (has-class? nil "p1") + (catch js/Error e + "Error")) + false (has-class? (by-id "id1") nil)))))) + +;;; value +(deftest value-test + (testing "Unit Testing for (value content)\n" + (testing "Edge Cases\n" + (testing "(value single-node)" + (are [expected actual] (= expected actual) + "Error" (try + (value (by-id nil)) + (catch js/Error e + "Error")) + "Error" (try + (value (by-id "")) + (catch js/Error e + "Error")) + "Error" (try + (value (by-id " ")) + (catch js/Error e + "Error")) + "Error" (try + (value (by-id "not-existent-id")) + (catch js/Error e + "Error"))))))) diff --git a/test/cljs/domina_standard_test.cljs b/test/cljs/domina_standard_test.cljs new file mode 100644 index 0000000..9b3ae44 --- /dev/null +++ b/test/cljs/domina_standard_test.cljs @@ -0,0 +1,193 @@ +(ns domina-standard-test + (:require-macros [cemerick.cljs.test :as m :refer (deftest testing are use-fixtures)] + [domina.macros :as dm] + [hiccups.core :as hm]) + (:require [cemerick.cljs.test :as t] + [domina :as dom :refer (nodes + single-node + by-id + by-class + append! + clone + detach! + destroy! + destroy-children! + children + insert-before!)] + [domina.fixtures :as fix :refer (base-fixture)] + [domina.xpath :as xp :refer (xpath)] + [hiccups.runtime :as hrt])) + +(use-fixtures :each base-fixture) + +;;; nodes +(deftest nodes-test + (testing "Unit Testing for (nodes content)\n" + (testing "Standard Cases\n" + (testing "(nodes content)" + (are [expected actual] (= expected actual) + 1 (count (nodes (xpath "//body"))) + 1 (count (nodes (xpath "//body/div"))) + 1 (count (nodes (xpath "//div[@class='d1']")))))))) + +;;; single-node +(deftest single-node-test + (testing "Unit Testing for (single-node node)\n" + (testing "Standard Cases\n" + (testing "(single-node node)" + (are [expected actual] (= expected actual) + false (nil? (single-node (xpath "//p"))) + false (nil? (single-node (by-class "p1"))) + false (nil? (single-node (by-id "id1")))))))) + +;;; by-id +(deftest by-id-test + (testing "Unit Testing for (by-id id)\n" + (testing "Standard Cases\n" + (testing "(by-id id)" + (are [expected actual] (= expected actual) + false (nil? (by-id "id1"))))))) + +;;; by-class +(deftest by-class-test + (testing "Unit Testing for (by-class css-class)\n" + (testing "Standard Cases\n" + (testing "(by-class css-class)" + (are [expected actual] (= expected actual) + 1 (count (by-class "p3")) + 2 (do + (append! (xpath "//body") + (hm/html [:p.tc "test1"] + [:p.tc "test2"])) + (count (nodes (by-class "tc"))))))))) + +;;; append! +(deftest append!-test + (testing "Unit Testing for (append! parent-content child-content)\n" + (testing "Standard Cases\n" + (testing "(append! single-parent single-child)" + (are [expected actual] (= expected actual) + 1 (do + (children (append! (xpath "//body") + (hm/html [:p.appended1 "test"]))) + (count (nodes (xpath "//body/p[@class='appended1']")))))) + (testing "Standard Cases\n" + (testing "(append! single-parent children)" + (are [expected actual] (= expected actual) + 2 (do + (append! (xpath "//body") + (hm/html [:p.appended2 "test2-1"] + [:p.appended2 "test2-2"])) + (count (nodes (xpath "//body/p[@class='appended2']")))))) + (testing "(append! multiple-parent single-child)" + (are [expected actual] (= expected actual) + 3 (do + (append! (xpath "//body/div/p") + (hm/html [:span "!!"])) + (count (nodes (xpath "//div/p/span")))))) + (testing "(append! multiple-parent children)" + (are [expected actual] (= expected actual) + 3 (do + (append! (xpath "//body/div/p") + (hm/html ["some " [:span.foo "more"] "text"])) + (count (nodes (xpath "//div/p/span[@class='foo']")))))))))) + +;;; detach! +(deftest detach!-test + (testing "Unit Testing for (detach! content)\n" + (testing "Standard Cases\n" + (testing "(detach! single-node)" + (are [expected actual] (= expected actual) + 0 (do + (detach! (xpath "//p[@class='p3']")) + (count (nodes (xpath "//p[@class='p3']")))))) + (testing "(detach! multiple-nodes)" + (are [expected actual] (= expected actual) + 0 (do + (detach! (xpath "//div[@class='d1']/p")) + (count (nodes (xpath "//div[@class='d1']/p")))) + 0 (do + (detach! (children "//div[@class='d1']")) + (count (children "//div[@class='d1']")))))))) + +;;; children +(deftest children-test + (testing "Unit Testing for (children content)\n" + (testing "Standard Cases\n" + (testing "(children content)" + (are [expected actual] (= expected actual) + 3 (count (children (xpath "//div[@class='d1']")))))))) + +;;; clone +(deftest clone-test + (testing "Unit Testing for (clone single-node)\n" + (testing "Standard Cases\n" + (testing "(clone single-node)" + (are [expected actual] (= expected actual) + 1 (count (clone (single-node (xpath "//p")))))) + (testing "(clone multiple-nodes)" + (are [expected actual] (= expected actual) + 3 (count (clone (nodes (xpath "//p"))))))))) + +;;; destroy! +(deftest destroy!-test + (testing "Unit Testing for (destroy! content)\n" + (testing "Standard Cases\n" + (testing "(destroy! single-node)" + (are [expected actual] (= expected actual) + 0 (do (append! (xpath "//body") + (hm/html [:p.appended1 "app1"])) + (destroy! (xpath "//body/p[@class='appended1']")) + (count (nodes (xpath "//body/p[@class='appended1']")))))) + (testing "(destroy! multiple-nodes)" + (are [expected actual] (= expected actual) + 0 (do (append! (xpath "//body") + (hm/html [:p.appended2 "app1"] + [:p.appended2 "app2"])) + (destroy! (xpath "//body/p[@class='appended2']")) + (count (nodes (xpath "//body/p[@class='appended2']"))))))))) + +;;; destroy-children! +(deftest destroy-children!-test + (testing "Unit Testing for (destroy-children! content)\n" + (testing "Standard Cases\n" + (testing "(destroy-children! single-node)" + (are [expected actual] (= expected actual) + 0 (do + (destroy-children! (xpath "//div[@class='d1']")) + (count (nodes (xpath "//div[@class='d1']/*"))))))))) + +;;; insert-before! +(deftest insert_before!-test + (testing "Unit Testing for (insert-before! ref-nodes new-nodes)\n" + (testing "Standard Cases\n" + (testing "(insert-before! single-ref-node single-node)" + (are [expected actual] (= expected actual) + 1 (do + (append! (xpath "//body") + (hm/html [:div#ref "Some Content"])) + (insert-before! (nodes (by-id "ref")) "

before

") + (count (nodes (xpath "//div[@id='ref']/preceding-sibling::*[text()='before']")))))) + (testing "(insert-before! single-ref-node multiple-nodes)" + (are [expected actual] (= expected actual) + 2 (do (append! (xpath "//body") + (hm/html [:div#ref "some content"])) + (insert-before! (nodes (by-id "ref")) + (hm/html [:p "before1"] + [:p "before2"])) + (+ (count (nodes (xpath "//div[@id='ref']/preceding-sibling::*[text()='before2' and position()=1]"))) + (count (nodes (xpath "//div[@id='ref']/preceding-sibling::*[text()='before1' and position()=2]")))))))))) + +;;; insert-before! +(deftest insert_before!!-test + (testing "Unit Testing for (insert-before! ref-nodes new-nodes)\n" + (testing "Standard Cases\n" + (testing "(insert-before! multiple-ref-nodes single-node)" + (are [expected actual] (= expected actual) + 5 (do + (append! (xpath "//body") (hm/html [:div#ref1.ref "content1"])) + (append! (xpath "//body") (hm/html [:div#ref2.ref "content2"])) + (insert-before! (nodes (by-class "ref")) (hm/html [:p "before"])) + (+ (count (nodes (xpath "//div[@class='ref']"))) + (count (nodes (xpath "//div[@id='ref1']/preceding-sibling::p"))) + (count (nodes (xpath "//div[@id='ref2']/preceding-sibling::p")))))))))) From 7af612601c8cebd027202a3dc031b8d754ac816b Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Wed, 6 Nov 2013 20:15:50 +0100 Subject: [PATCH 14/52] add more unit tests --- test/cljs/domina/css_edge_test.cljs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/cljs/domina/css_edge_test.cljs diff --git a/test/cljs/domina/css_edge_test.cljs b/test/cljs/domina/css_edge_test.cljs new file mode 100644 index 0000000..8d27fdf --- /dev/null +++ b/test/cljs/domina/css_edge_test.cljs @@ -0,0 +1,22 @@ +(ns domina.css-edge-test + (:require-macros [cemerick.cljs.test :as m :refer (deftest testing are use-fixtures)] + [domina.macros :as dm]) + (:require [cemerick.cljs.test :as t] + [domina :as dom] + [domina.css :as css] + [domina.fixtures :as fix :refer (base-fixture)])) + +(use-fixtures :each base-fixture) + +;;; sel +#_(deftest sel-test + (testing "Unit Testing for (sel css-expr)\n" + (testing "Edge Cases\n" + (are [expected actual] (= expected actual) + nil (css/sel nil) + nil (css/sel "") + nil (css/sel " ") + 0 (count (dom/nodes (css/sel ".not-existent-css-class"))) + 0 (count (dom/nodes (css/sel "#not-existent-id"))) + 0 (count (dom/nodes (css/sel ".not existent css class"))) + 0 (count (dom/nodes (css/sel "#not existent css id"))))))) From 687331a19db689cc09314544027547ee70a1b8c7 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Wed, 6 Nov 2013 23:08:15 +0100 Subject: [PATCH 15/52] update rules --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1dbeeb3..7ebe1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,13 +5,16 @@ public/build_no_opt public/test_*.js public/domina.js domina-tests +.lein-repl-history lib +out +dev-resources/public/js/*.js *.jar .repl pom.xml .lein-plugins .lein-failures -/target +target *.*~ \#*# .#* From dc14db9420d1af66b907878513c5fd08e6151836 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Wed, 6 Nov 2013 23:09:45 +0100 Subject: [PATCH 16/52] update cljs to r1978 and cljsbuild to 1.0.0-alpha1 --- project.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project.clj b/project.clj index 95b1f71..95f3bdb 100644 --- a/project.clj +++ b/project.clj @@ -2,8 +2,8 @@ :description "A DOM manipulation library for ClojureScript inspired by JQuery" :source-paths ["src/clj" "src/cljs"] :dependencies [[org.clojure/clojure "1.5.1"] - [org.clojure/clojurescript "0.0-1847"]] - :plugins [[lein-cljsbuild "0.3.2"]] + [org.clojure/clojurescript "0.0-1978"]] + :plugins [[lein-cljsbuild "1.0.0-alpha1"]] :hooks [leiningen.cljsbuild] :cljsbuild {:builds {:deploy {:source-paths ["src/cljs"] From dfe37f713a32cd22ba6e1af6ac1d05762cb5f770 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Wed, 6 Nov 2013 23:15:36 +0100 Subject: [PATCH 17/52] update edge unit tests --- test/cljs/domina/css_edge_test.cljs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/cljs/domina/css_edge_test.cljs b/test/cljs/domina/css_edge_test.cljs index 8d27fdf..b3c7e13 100644 --- a/test/cljs/domina/css_edge_test.cljs +++ b/test/cljs/domina/css_edge_test.cljs @@ -2,21 +2,19 @@ (:require-macros [cemerick.cljs.test :as m :refer (deftest testing are use-fixtures)] [domina.macros :as dm]) (:require [cemerick.cljs.test :as t] - [domina :as dom] - [domina.css :as css] + [domina :as dom :refer (nodes)] + [domina.css :as css :refer (sel)] [domina.fixtures :as fix :refer (base-fixture)])) (use-fixtures :each base-fixture) ;;; sel -#_(deftest sel-test +(deftest sel-test (testing "Unit Testing for (sel css-expr)\n" (testing "Edge Cases\n" (are [expected actual] (= expected actual) - nil (css/sel nil) - nil (css/sel "") - nil (css/sel " ") - 0 (count (dom/nodes (css/sel ".not-existent-css-class"))) - 0 (count (dom/nodes (css/sel "#not-existent-id"))) - 0 (count (dom/nodes (css/sel ".not existent css class"))) - 0 (count (dom/nodes (css/sel "#not existent css id"))))))) + false (nil? (sel nil)) + false (nil? (sel "")) + false (nil? (sel " ")) + 0 (count (nodes (sel ".not-existent-css-class"))) + 0 (count (nodes (sel "#not-existent-css-id"))))))) From 18d5b5ef903b18ce98c59b0a878d15b9bda01739 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Thu, 7 Nov 2013 11:10:41 +0100 Subject: [PATCH 18/52] update cljs to r2014 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 95f3bdb..7df6ab0 100644 --- a/project.clj +++ b/project.clj @@ -2,7 +2,7 @@ :description "A DOM manipulation library for ClojureScript inspired by JQuery" :source-paths ["src/clj" "src/cljs"] :dependencies [[org.clojure/clojure "1.5.1"] - [org.clojure/clojurescript "0.0-1978"]] + [org.clojure/clojurescript "0.0-2014"]] :plugins [[lein-cljsbuild "1.0.0-alpha1"]] :hooks [leiningen.cljsbuild] :cljsbuild {:builds {:deploy From c6153fb0615b58234d8d14a82af5413e599a069a Mon Sep 17 00:00:00 2001 From: magomimmo Date: Thu, 7 Nov 2013 14:27:47 +0100 Subject: [PATCH 19/52] comment other tests already implemented with clojurescript.test lib --- temp/test/cljs/domina/test.cljs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/temp/test/cljs/domina/test.cljs b/temp/test/cljs/domina/test.cljs index f158747..050558c 100644 --- a/temp/test/cljs/domina/test.cljs +++ b/temp/test/cljs/domina/test.cljs @@ -69,28 +69,28 @@ ;;;;;; CSS selection tests -(add-test "basic CSS selection" +#_(add-test "basic CSS selection" #(do (reset) (standard-fixture) (assert (= 3 (count (nodes (sel "p"))))))) -(add-test "basic CSS selection (single node)" +#_(add-test "basic CSS selection (single node)" #(do (reset) (standard-fixture) (assert (not (nil? (single-node (sel "p"))))))) -(add-test "CSS selection with class specification" +#_(add-test "CSS selection with class specification" #(do (reset) (standard-fixture) (assert (= 1 (count (nodes (sel ".d1"))))))) -(add-test "a relative CSS selector" +#_(add-test "a relative CSS selector" #(do (reset) (standard-fixture) (assert (= 3 (count (nodes (-> (sel ".d1") (sel "p")))))))) -(add-test "extended CSS chaining" +#_(add-test "extended CSS chaining" #(do (reset) (append! (sel "body") "

some text

more text

") @@ -101,28 +101,28 @@ ;;;;;; DOM Manipulation Tests -add-test "basic xpath selection" -#(do (reset) - (standard-fixture) - (assert (= 3 (count (nodes (xpath "//p")))))) +#_(add-test "basic xpath selection" + #(do (reset) + (standard-fixture) + (assert (= 3 (count (nodes (xpath "//p"))))))) -(add-test "basic xpath selection (single node)" +#_(add-test "basic xpath selection (single node)" #(do (reset) (standard-fixture) (assert (not (nil? (single-node (xpath "//p"))))))) -(add-test "xpath selection with class specification" +#_(add-test "xpath selection with class specification" #(do (reset) (standard-fixture) (assert (= 1 (count (nodes (xpath "//div[@class='d1']"))))))) -(add-test "a relative xpath expression" +#_(add-test "a relative xpath expression" #(do (reset) (standard-fixture) (assert (= 3 (count (nodes (-> (xpath "//body/div[@class='d1']") (xpath "p")))))))) -(add-test "extended selection chaining" +#_(add-test "extended selection chaining" #(do (reset) (append! (xpath "//body") "

some text

more text

") @@ -130,7 +130,7 @@ add-test "basic xpath selection" (xpath "./div") (xpath "./p") (xpath "./span")))))))) -(add-test "advanced xpath" +#_(add-test "advanced xpath" #(do (reset) (standard-fixture) (assert (= 2 (count (nodes (xpath "//p[following-sibling::p[@class='p3']]"))))))) @@ -140,7 +140,7 @@ add-test "basic xpath selection" (standard-fixture) (assert (= 1 (count (nodes (by-id "id1"))))))) -(add-test "look up node by id with context" +#_(add-test "look up node by id with context" #(do (reset) (append! (sel "body") "

some text

more text

") From 14ae284f3538a313c4b4882fbce26373d8759417 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Thu, 7 Nov 2013 14:28:31 +0100 Subject: [PATCH 20/52] completed xpath standard tests --- test/cljs/domina/xpath_standard_test.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cljs/domina/xpath_standard_test.cljs b/test/cljs/domina/xpath_standard_test.cljs index fbae33f..8dc64cd 100644 --- a/test/cljs/domina/xpath_standard_test.cljs +++ b/test/cljs/domina/xpath_standard_test.cljs @@ -28,4 +28,5 @@ (count (nodes (-> (xpath "//body") (xpath "./div") (xpath "./p") - (xpath "./span"))))))))) + (xpath "./span"))))) + 2 (count (nodes (xpath "//p[following-sibling::p[@class='p3']]"))))))) From 6822cb3339501f1b24298f1b91b9b6f2f1df80a0 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Thu, 7 Nov 2013 15:07:15 +0100 Subject: [PATCH 21/52] comment prepend! test --- temp/test/cljs/domina/test.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/temp/test/cljs/domina/test.cljs b/temp/test/cljs/domina/test.cljs index 050558c..9e8a63d 100644 --- a/temp/test/cljs/domina/test.cljs +++ b/temp/test/cljs/domina/test.cljs @@ -200,7 +200,7 @@ "some more text") (assert (= 3 (count (nodes (xpath "//div/p/span[@class='foo']"))))))) -(add-test "prepend a single child to a single parent" +#_(add-test "prepend a single child to a single parent" #(do (reset) (append! (xpath "//body") "
2
3
") (prepend! (xpath "//body") "
1
") From f5739d9a6884c610e1a4c95553cecb60f855396f Mon Sep 17 00:00:00 2001 From: magomimmo Date: Thu, 7 Nov 2013 15:07:41 +0100 Subject: [PATCH 22/52] add prepend! unit test --- test/cljs/domina_standard_test.cljs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/cljs/domina_standard_test.cljs b/test/cljs/domina_standard_test.cljs index 9b3ae44..e646283 100644 --- a/test/cljs/domina_standard_test.cljs +++ b/test/cljs/domina_standard_test.cljs @@ -13,7 +13,9 @@ destroy! destroy-children! children - insert-before!)] + insert-before! + prepend! + text)] [domina.fixtures :as fix :refer (base-fixture)] [domina.xpath :as xp :refer (xpath)] [hiccups.runtime :as hrt])) @@ -191,3 +193,16 @@ (+ (count (nodes (xpath "//div[@class='ref']"))) (count (nodes (xpath "//div[@id='ref1']/preceding-sibling::p"))) (count (nodes (xpath "//div[@id='ref2']/preceding-sibling::p")))))))))) + +;;; prepend! +(deftest prepend!-test + (testing "Unit Testing for (prepend! parents children)\n" + (testing "Standard Cases\n" + (testing "(prepend! single-parent single-child)" + (are [expected actual] (= expected actual) + 1 (do + (append! (xpath "//body") (hm/html [:div "2"] [:div "3"])) + (prepend! (xpath "//body") (hm/html [:div "1"])) + (count (+ (text (xpath "//body/div[1]")) + #_(text (xpath "//body/div[2]")) + #_(text (xpath "//body/div[3]")))))))))) From 528fac26fffe479440a172217f170d02c9955189 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Thu, 7 Nov 2013 19:01:30 +0100 Subject: [PATCH 23/52] update cljs.test to 0.2.0 --- profiles.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles.clj b/profiles.clj index 620f335..80cb2d3 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,6 +1,6 @@ {:dev {:test-paths ["test/cljs"] :dependencies [[hiccups "0.2.0"]] - :plugins [[com.cemerick/clojurescript.test "0.1.0"]] + :plugins [[com.cemerick/clojurescript.test "0.2.0"]] :cljsbuild {:builds {:none {:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] From 52a516b0059973bb932c5618858bc3ef379b4657 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Thu, 7 Nov 2013 19:32:06 +0100 Subject: [PATCH 24/52] comment few more tests --- temp/test/cljs/domina/test.cljs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/temp/test/cljs/domina/test.cljs b/temp/test/cljs/domina/test.cljs index 9e8a63d..48dc5e3 100644 --- a/temp/test/cljs/domina/test.cljs +++ b/temp/test/cljs/domina/test.cljs @@ -208,13 +208,13 @@ (assert (= "2" (text (xpath "//body/div[2]")))) (assert (= "3" (text (xpath "//body/div[3]")))))) -(add-test "prepend a single child to multiple parents" +#_(add-test "prepend a single child to multiple parents" #(do (reset) (append! (xpath "//body") "

2

2

") (prepend! (xpath "//body/div") "

1

") (assert (= 2 (count (nodes (xpath "//body/div/p[text()='2']"))))))) -(add-test "Insert a single child to a single parent" +#_(add-test "Insert a single child to a single parent" #(do (reset) (append! (xpath "//body") "
") @@ -316,20 +316,20 @@ (assert (= 1 (count (nodes (xpath "//div[@id='ref1']/preceding-sibling::p"))))) (assert (= 2 (count (nodes (xpath "//div[@id='ref2']/preceding-sibling::p"))))))) -(add-test "insert-after! with a single reference and single new node" +#_(add-test "insert-after! with a single reference and single new node" #(do (reset) (append! (xpath "//body") "
Some content
") (insert-after! (nodes (by-id "ref")) "

after

") (assert (= 1 (count (nodes (xpath "//div[@id='ref']/following-sibling::*[text()='after']"))))))) -(add-test "insert-after! with a single reference and multiple new nodes" +#_(add-test "insert-after! with a single reference and multiple new nodes" #(do (reset) (append! (xpath "//body") "
Some content
") (insert-after! (nodes (by-id "ref")) "

after1

after2

") (assert (= 1 (count (nodes (xpath "//div[@id='ref']/following-sibling::*[text()='after1' and position()=1]"))))) (assert (= 1 (count (nodes (xpath "//div[@id='ref']/following-sibling::*[text()='after2' and position()=2]"))))))) -(add-test "insert-after! with multiple reference nodes and a single new node" +#_(add-test "insert-after! with multiple reference nodes and a single new node" #(do (reset) (append! (xpath "//body") "
content1
") (append! (xpath "//body") "
content2
") From f830565c6520f817e55eb6051d29941f009c71c9 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Thu, 7 Nov 2013 19:33:13 +0100 Subject: [PATCH 25/52] add more unit tests --- test/cljs/domina_standard_test.cljs | 74 ++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/test/cljs/domina_standard_test.cljs b/test/cljs/domina_standard_test.cljs index e646283..3eae743 100644 --- a/test/cljs/domina_standard_test.cljs +++ b/test/cljs/domina_standard_test.cljs @@ -14,7 +14,9 @@ destroy-children! children insert-before! + insert-after! prepend! + insert! text)] [domina.fixtures :as fix :refer (base-fixture)] [domina.xpath :as xp :refer (xpath)] @@ -160,7 +162,7 @@ (count (nodes (xpath "//div[@class='d1']/*"))))))))) ;;; insert-before! -(deftest insert_before!-test +(deftest insert-before!-test (testing "Unit Testing for (insert-before! ref-nodes new-nodes)\n" (testing "Standard Cases\n" (testing "(insert-before! single-ref-node single-node)" @@ -181,7 +183,7 @@ (count (nodes (xpath "//div[@id='ref']/preceding-sibling::*[text()='before1' and position()=2]")))))))))) ;;; insert-before! -(deftest insert_before!!-test +(deftest insert-before!!-test (testing "Unit Testing for (insert-before! ref-nodes new-nodes)\n" (testing "Standard Cases\n" (testing "(insert-before! multiple-ref-nodes single-node)" @@ -199,10 +201,68 @@ (testing "Unit Testing for (prepend! parents children)\n" (testing "Standard Cases\n" (testing "(prepend! single-parent single-child)" - (are [expected actual] (= expected actual) - 1 (do + (are [expected actual] (= expected actual) + "1" (do (append! (xpath "//body") (hm/html [:div "2"] [:div "3"])) (prepend! (xpath "//body") (hm/html [:div "1"])) - (count (+ (text (xpath "//body/div[1]")) - #_(text (xpath "//body/div[2]")) - #_(text (xpath "//body/div[3]")))))))))) + (text (xpath "//body/div[1]"))))) + (testing "(prepend! parents single-child)" + (are [expected actual] (= expected actual) + 2 (do (append! (xpath "//body") "

2

2

") + (prepend! (xpath "//body/div") "

1

") + (count (nodes (xpath "//body/div/p[text()='2']"))))))))) + +(deftest insert!-test + (testing "Unit Testing for (insert! parents children)\n" + (testing "Standard Cases\n" + (testing "(insert! parent child)" + (are [expected actual] (= expected actual) + 5 (do + (append! (xpath "//body") + (hm/html [:div.testInserts])) + (append! (xpath "//div[@class='testInserts']") + (hm/html [:p.i1])) + (append! (xpath "//div[@class='testInserts']") + (hm/html [:p.i3])) + (insert! (xpath "//div[@class='testInserts']") + (hm/html [:p.i2]) 1) + (+ (count (nodes (xpath "//div[@class='testInserts']/p"))) + (count (nodes (xpath "//p[@class='i2']/preceding-sibling::*"))) + (count (nodes (xpath "//p[@class='i2']/following-sibling::*"))))))) + (testing "(insert! parents single-child)" + (are [expected actual] (= expected actual) + true false))))) + + +(deftest insert-after!-test + (testing "Unit Testing for (insert-after! ref-nodes new-nodes)\n" + (testing "Standard Cases\n" + (testing "(insert-after! single-ref-node single-node)" + (are [expected actual] (= expected actual) + 1 (do + (append! (xpath "//body") + (hm/html [:div#ref "Some content"])) + (insert-after! (nodes (by-id "ref")) + (hm/html [:p "after"])) + (count (nodes (xpath "//div[@id='ref']/following-sibling::*[text()='after']")))))) + (testing "(insert-after! single-ref-node multiple-nodes)" + (are [expected actual] (= expected actual) + 2 (do + (append! (xpath "//body") + (hm/html [:div#ref "Some content"])) + (insert-after! (nodes (by-id "ref")) + (hm/html [:p "after1"] + [:p "after2"])) + (+ (count (nodes (xpath "//div[@id='ref']/following-sibling::*[text()='after1' and position()=1]"))) + (count (nodes (xpath "//div[@id='ref']/following-sibling::*[text()='after2' and position()=2]"))))))) + (testing "(insert-after! multiple-ref-node multiple-nodes)" + (are [expected actual] (= expected actual) + 3 (do + (append! (xpath "//body") + (hm/html [:div#ref1.ref "content1"])) + (append! (xpath "//body") + (hm/html [:div#ref2.ref "content2"])) + (insert-after! (nodes (by-class "ref")) + (hm/html [:p "after"])) + (+ (count (nodes (xpath "//div[@id='ref1']/following-sibling::p"))) + (count (nodes (xpath "//div[@id='ref2']/following-sibling::p")))))))))) From 3b13f9daba07e41198e219effea106930952ef9c Mon Sep 17 00:00:00 2001 From: magomimmo Date: Fri, 8 Nov 2013 00:32:22 +0100 Subject: [PATCH 26/52] comment other 3 tests --- temp/test/cljs/domina/test.cljs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/temp/test/cljs/domina/test.cljs b/temp/test/cljs/domina/test.cljs index 48dc5e3..f5bc46c 100644 --- a/temp/test/cljs/domina/test.cljs +++ b/temp/test/cljs/domina/test.cljs @@ -338,21 +338,21 @@ (assert (= 2 (count (nodes (xpath "//div[@id='ref1']/following-sibling::p"))))) (assert (= 1 (count (nodes (xpath "//div[@id='ref2']/following-sibling::p"))))))) -(add-test "swap-content! with a single reference node and a single new node" +#_(add-test "swap-content! with a single reference node and a single new node" #(do (reset) (append! (xpath "//body") "

TYPO

") (swap-content! (xpath "//p[@id='before']") "

fixed

") (assert (= 0 (count (nodes (xpath "//p[@id='before']"))))) (assert (= 1 (count (nodes (xpath "//p[@id='after']"))))))) -(add-test "swap-content! with a single reference node and multiple new nodes" +#_(add-test "swap-content! with a single reference node and multiple new nodes" #(do (reset) (append! (xpath "//body") "

TYPO

") (swap-content! (xpath "//p[@id='before']") "

fixed1

fixed2

") (assert (= 0 (count (nodes (xpath "//p[@id='before']"))))) (assert (= 2 (count (nodes (xpath "//p[@class='after']"))))))) -(add-test "swap-content! with multiple reference nodes and multiple new nodes" +#_(add-test "swap-content! with multiple reference nodes and multiple new nodes" #(do (reset) (append! (xpath "//body") "

TYPO-1

") (append! (xpath "//body") "

TYPO-2

") From 221f7200452c9d19b434460c7eb3496f8f29a8ad Mon Sep 17 00:00:00 2001 From: magomimmo Date: Fri, 8 Nov 2013 00:33:22 +0100 Subject: [PATCH 27/52] add other unit tests --- test/cljs/domina_standard_test.cljs | 48 +++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/test/cljs/domina_standard_test.cljs b/test/cljs/domina_standard_test.cljs index 3eae743..cae50d0 100644 --- a/test/cljs/domina_standard_test.cljs +++ b/test/cljs/domina_standard_test.cljs @@ -17,6 +17,7 @@ insert-after! prepend! insert! + swap-content! text)] [domina.fixtures :as fix :refer (base-fixture)] [domina.xpath :as xp :refer (xpath)] @@ -208,8 +209,13 @@ (text (xpath "//body/div[1]"))))) (testing "(prepend! parents single-child)" (are [expected actual] (= expected actual) - 2 (do (append! (xpath "//body") "

2

2

") - (prepend! (xpath "//body/div") "

1

") + 2 (do (append! (xpath "//body") + (hm/html [:div [:p "2"]] + [:div [:p "2"]]) + #_"

2

2

") + (prepend! (xpath "//body/div") + (hm/html [:p "1"]) + #_"

1

") (count (nodes (xpath "//body/div/p[text()='2']"))))))))) (deftest insert!-test @@ -233,7 +239,7 @@ (are [expected actual] (= expected actual) true false))))) - +;;; insert-after! (deftest insert-after!-test (testing "Unit Testing for (insert-after! ref-nodes new-nodes)\n" (testing "Standard Cases\n" @@ -266,3 +272,39 @@ (hm/html [:p "after"])) (+ (count (nodes (xpath "//div[@id='ref1']/following-sibling::p"))) (count (nodes (xpath "//div[@id='ref2']/following-sibling::p")))))))))) + +;;; swap-content! +(deftest swap-content!-test + (testing "Unit Testing for (swap-content! old-content new-content)\n" + (testing "Standard Cases\n" + (testing "(swap-content! single-old-node single-new-node)" + (are [expected actual] (= expected actual) + 1 (do + (append! (xpath "//body") + (hm/html [:div [:p#before "TYPO"]])) + (swap-content! (xpath "//p[@id='before']") + (hm/html [:p#after "fixed"])) + (+ (count (nodes (xpath "//p[@id='before']"))) + (count (nodes (xpath "//p[@id='after']"))))))) + (testing "(swap-content! single-ref-node multiple-new-node)" + (are [expected actual] (= expected actual) + 2 (do + (append! (xpath "//body") + (hm/html [:div [:p#before "TYPE"]])) + (swap-content! (xpath "//p[@id='before']") + (hm/html [:p.after "fixed1"] + [:p.after "fixed2"])) + (+ (count (nodes (xpath "//p[@id='before']"))) + (count (nodes (xpath "//p[@class='after']"))))))) + (testing "(swap-content! multiple-ref-nodes multiple-new-node)" + (are [expected actual] (= expected actual) + 4 (do + (append! (xpath "//body") + (hm/html [:div [:p.before1 "TYPO-1"]])) + (append! (xpath "//body") + (hm/html [:div [:p.before1"TYPO-2"]])) + (swap-content! (xpath "//p[@class='before1']") + (hm/html [:p.after1 "fixed1"] + [:p.after1 "fixed2"])) + (+ (count (nodes (xpath "//p[@class='before1']"))) + (count (nodes (xpath "//p[@class='after1']")))))))))) From 3fd5cebfa430f17eaada79c0a475590a9c43f541 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Fri, 8 Nov 2013 00:34:24 +0100 Subject: [PATCH 28/52] comment builds and tests to speedup round trip --- profiles.clj | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/profiles.clj b/profiles.clj index 80cb2d3..3fc4e59 100644 --- a/profiles.clj +++ b/profiles.clj @@ -13,14 +13,14 @@ :optimizations :whitespace :pretty-print true :output-to "dev-resources/public/js/whitespace.js"}} - :simple - {:source-paths ["src/cljs" "test/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :optimizations :simple - :pretty-print true - :output-to "dev-resources/public/js/simple.js"}} - :advanced - {:source-paths ["src/cljs" "test/cljs"] + #_:simple + #_{:source-paths ["src/cljs" "test/cljs"] + :compiler {:libs ["goog/dom/query.js"] + :optimizations :simple + :pretty-print true + :output-to "dev-resources/public/js/simple.js"}} + #_:advanced + #_{:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :advanced :pretty-print true @@ -28,8 +28,8 @@ :test-commands {"whitespace" ["phantomjs" :runner "dev-resources/public/js/whitespace.js"] - "simple" - ["phantomjs" :runner "dev-resources/public/js/simple.js"] + #_"simple" + #_["phantomjs" :runner "dev-resources/public/js/simple.js"] - "advanced" - ["phantomjs" :runner "dev-resources/public/js/advanced.js"]}}}} + #_"advanced" + #_["phantomjs" :runner "dev-resources/public/js/advanced.js"]}}}} From 80f0eb64835e26da117bcc75f66b46aa1f380fed Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Fri, 8 Nov 2013 15:19:32 +0100 Subject: [PATCH 29/52] commented out :none build and test to speedup lifecycle until the unit tests are completed --- profiles.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/profiles.clj b/profiles.clj index 3fc4e59..8d0b4e8 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,8 +1,8 @@ {:dev {:test-paths ["test/cljs"] :dependencies [[hiccups "0.2.0"]] :plugins [[com.cemerick/clojurescript.test "0.2.0"]] - :cljsbuild {:builds {:none - {:source-paths ["src/cljs" "test/cljs"] + :cljsbuild {:builds {#_:none + #_{:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] :pretty-print true :optimizations :none From 7dfb5f5d3d17181e261f233d5f704cba8c705082 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Sat, 9 Nov 2013 13:06:58 +0100 Subject: [PATCH 30/52] update cljs to r2030 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 7df6ab0..74df297 100644 --- a/project.clj +++ b/project.clj @@ -2,7 +2,7 @@ :description "A DOM manipulation library for ClojureScript inspired by JQuery" :source-paths ["src/clj" "src/cljs"] :dependencies [[org.clojure/clojure "1.5.1"] - [org.clojure/clojurescript "0.0-2014"]] + [org.clojure/clojurescript "0.0-2030"]] :plugins [[lein-cljsbuild "1.0.0-alpha1"]] :hooks [leiningen.cljsbuild] :cljsbuild {:builds {:deploy From e3edc268feb3af762100dd728438e3ad49bd1b84 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 12:59:02 +0100 Subject: [PATCH 31/52] update cljsbuild to 1.0.0-alpha2 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 74df297..4910e71 100644 --- a/project.clj +++ b/project.clj @@ -3,7 +3,7 @@ :source-paths ["src/clj" "src/cljs"] :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojurescript "0.0-2030"]] - :plugins [[lein-cljsbuild "1.0.0-alpha1"]] + :plugins [[lein-cljsbuild "1.0.0-alpha2"]] :hooks [leiningen.cljsbuild] :cljsbuild {:builds {:deploy {:source-paths ["src/cljs"] From c33c5e139c79f10ce06ac13b37b2905603a7f5b8 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 13:20:05 +0100 Subject: [PATCH 32/52] add austin plugin --- profiles.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/profiles.clj b/profiles.clj index 8d0b4e8..698705d 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,6 +1,7 @@ {:dev {:test-paths ["test/cljs"] :dependencies [[hiccups "0.2.0"]] - :plugins [[com.cemerick/clojurescript.test "0.2.0"]] + :plugins [[com.cemerick/clojurescript.test "0.2.0"] + [com.cemerick/austin "0.1.3"]] :cljsbuild {:builds {#_:none #_{:source-paths ["src/cljs" "test/cljs"] :compiler {:libs ["goog/dom/query.js"] From 455614525bc587915a12114df3b1c0ab46ef466f Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 13:45:30 +0100 Subject: [PATCH 33/52] add ring, compojure and enlive to run a very thiny server --- profiles.clj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/profiles.clj b/profiles.clj index 698705d..ea1755d 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,5 +1,8 @@ {:dev {:test-paths ["test/cljs"] - :dependencies [[hiccups "0.2.0"]] + :dependencies [[hiccups "0.2.0"] + [ring "1.2.1"] + [compojure "1.1.6"] + [enlive "1.1.4"]] :plugins [[com.cemerick/clojurescript.test "0.2.0"] [com.cemerick/austin "0.1.3"]] :cljsbuild {:builds {#_:none From 4147bc4093ca1d05dc2e008eabe5d4096f8b0b01 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:05:00 +0100 Subject: [PATCH 34/52] add dev-resources to :resource-paths and add dev-resources/clj to test-paths --- profiles.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/profiles.clj b/profiles.clj index ea1755d..b511fa0 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,4 +1,5 @@ -{:dev {:test-paths ["test/cljs"] +{:dev {:resource-paths ["dev-resources"] + :test-paths ["dev-resources/clj" "test/cljs"] :dependencies [[hiccups "0.2.0"] [ring "1.2.1"] [compojure "1.1.6"] From 5c9916d74e35554dfd3134bc301ce542e48fe968 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:06:33 +0100 Subject: [PATCH 35/52] add index.html to supporto brepl with austin --- dev-resources/public/index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 dev-resources/public/index.html diff --git a/dev-resources/public/index.html b/dev-resources/public/index.html new file mode 100644 index 0000000..07bc7d9 --- /dev/null +++ b/dev-resources/public/index.html @@ -0,0 +1,14 @@ + + + + + bREPL Connection + + + + + + + From 901206a662de86983587052c36362eb135662fca Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:07:39 +0100 Subject: [PATCH 36/52] add stuff to support austin brepl --- dev-resources/clj/domina/server.clj | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 dev-resources/clj/domina/server.clj diff --git a/dev-resources/clj/domina/server.clj b/dev-resources/clj/domina/server.clj new file mode 100644 index 0000000..3ed2771 --- /dev/null +++ b/dev-resources/clj/domina/server.clj @@ -0,0 +1,23 @@ +(ns domina.server + (:require [cemerick.austin.repls :refer (browser-connected-repl-js)] + [net.cgrand.enlive-html :as enlive] + [compojure.route :refer (resources)] + [compojure.core :refer (GET defroutes)] + ring.adapter.jetty + [clojure.java.io :as io])) + +(enlive/deftemplate page + (io/resource "public/index.html") + [] + [:body] (enlive/append + (enlive/html [:script (browser-connected-repl-js)]))) + +(defroutes site + (resources "/") + (GET "/*" req (page))) + +(defn run + [] + (defonce server + (ring.adapter.jetty/run-jetty #'site {:port 8080 :join? false})) + server) From 26945090bd71c40acbddb80db6563c054844faa1 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:13:09 +0100 Subject: [PATCH 37/52] add repl-options --- profiles.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/profiles.clj b/profiles.clj index b511fa0..676fba4 100644 --- a/profiles.clj +++ b/profiles.clj @@ -37,4 +37,5 @@ #_["phantomjs" :runner "dev-resources/public/js/simple.js"] #_"advanced" - #_["phantomjs" :runner "dev-resources/public/js/advanced.js"]}}}} + #_["phantomjs" :runner "dev-resources/public/js/advanced.js"]}} + :repl-options {:init-ns domina.server}}} From 9ad0fe5fff83c51cf8d36c1b4df17c3a7ba5566c Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:44:52 +0100 Subject: [PATCH 38/52] move emitted js into the head --- dev-resources/public/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-resources/public/index.html b/dev-resources/public/index.html index 07bc7d9..7d12fac 100644 --- a/dev-resources/public/index.html +++ b/dev-resources/public/index.html @@ -6,9 +6,9 @@ + - - + From 6007cd023de16a824a229fd0b260ed1af19d0363 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:46:04 +0100 Subject: [PATCH 39/52] add dev-resources/cljs to test-paths and to whitespace build --- profiles.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/profiles.clj b/profiles.clj index 676fba4..fa498d0 100644 --- a/profiles.clj +++ b/profiles.clj @@ -1,5 +1,5 @@ {:dev {:resource-paths ["dev-resources"] - :test-paths ["dev-resources/clj" "test/cljs"] + :test-paths ["dev-resources/clj" "test/cljs" "dev-resources/cljs"] :dependencies [[hiccups "0.2.0"] [ring "1.2.1"] [compojure "1.1.6"] @@ -13,7 +13,7 @@ :optimizations :none :output-to "dev-resources/public/js/none.js"}} :whitespace - {:source-paths ["src/cljs" "test/cljs"] + {:source-paths ["src/cljs" "test/cljs" "dev-resources/cljs"] :compiler {:libs ["goog/dom/query.js"] :optimizations :whitespace :pretty-print true From c8f8ecabac5a607b109c8c97bbf4df25181f6ea0 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:46:41 +0100 Subject: [PATCH 40/52] add brepl connection --- dev-resources/cljs/domina/brepl.cljs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 dev-resources/cljs/domina/brepl.cljs diff --git a/dev-resources/cljs/domina/brepl.cljs b/dev-resources/cljs/domina/brepl.cljs new file mode 100644 index 0000000..5216834 --- /dev/null +++ b/dev-resources/cljs/domina/brepl.cljs @@ -0,0 +1,6 @@ +(ns domina.brepl + (:require [clojure.browser.repl])) + +(defn whoami + [] + (.-userAgent js/navigator)) From 41a895dff5db16104eeeff852bfd4201b7463b1d Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 14:54:45 +0100 Subject: [PATCH 41/52] update rules --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 7ebe1b0..a626d07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ classes .cljsbuild .lein-deps-sum -public/build_no_opt -public/test_*.js -public/domina.js -domina-tests .lein-repl-history lib out From a9e7e61723fb4b7d9df832352f0606a9fe5e8023 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 15:19:14 +0100 Subject: [PATCH 42/52] remove public dirs --- public/test_advanced.html | 27 ---- public/test_ie.html | 12 -- public/test_no_opt.html | 31 ---- public/test_simple.html | 27 ---- public/test_whitespace.html | 27 ---- public/tests.css | 44 ------ public/xpath.js | 288 ------------------------------------ 7 files changed, 456 deletions(-) delete mode 100644 public/test_advanced.html delete mode 100644 public/test_ie.html delete mode 100644 public/test_no_opt.html delete mode 100644 public/test_simple.html delete mode 100644 public/test_whitespace.html delete mode 100644 public/tests.css delete mode 100644 public/xpath.js diff --git a/public/test_advanced.html b/public/test_advanced.html deleted file mode 100644 index 623ce24..0000000 --- a/public/test_advanced.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - Domina Test Page (advanced optimizations) - - - - - - - - diff --git a/public/test_ie.html b/public/test_ie.html deleted file mode 100644 index 47cca56..0000000 --- a/public/test_ie.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Domina Test Page (IE tests) - - - - - - - diff --git a/public/test_no_opt.html b/public/test_no_opt.html deleted file mode 100644 index 8167ea3..0000000 --- a/public/test_no_opt.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - Domina Test Page (no optimizations) - - - - - - - - - - diff --git a/public/test_simple.html b/public/test_simple.html deleted file mode 100644 index 160ac83..0000000 --- a/public/test_simple.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - Domina Test Page (simple optimizations) - - - - - - - - diff --git a/public/test_whitespace.html b/public/test_whitespace.html deleted file mode 100644 index effbd85..0000000 --- a/public/test_whitespace.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - Domina Test Page (whitespace optimizations) - - - - - - - - diff --git a/public/tests.css b/public/tests.css deleted file mode 100644 index 9999483..0000000 --- a/public/tests.css +++ /dev/null @@ -1,44 +0,0 @@ -#test-summary { - font-size: 1.5em; - font-weight: bold; - text-align: center; -} - -#test-summary.failed { - color: darkred; -} - -#test-summary.passed { - color: darkgreen; -} - -#test-summary.passed { - color: darkgreen; -} - -.test-result { - margin: 0.5em; - padding: 0.5em; - border: 1px solid black; - border-radius: 7px; -} - -.test-result.passed { - background-color: lightgreen; - color: darkgreen; - border-color: darkgreen; -} - -.test-result.failed { - background-color: pink; - color: darkred; - border-color: darkred; -} - -.message { - background-color: white; - border: 1px solid; - border-radius: 7px; - padding: 0.5em; - margin-top: 0.5em; -} \ No newline at end of file diff --git a/public/xpath.js b/public/xpath.js deleted file mode 100644 index 7e8073a..0000000 --- a/public/xpath.js +++ /dev/null @@ -1,288 +0,0 @@ -(function(){var ca=void(0);var da={targetFrame:ca,exportInstaller:false,useNative:true,useInnerText:true};var ea;if(window.jsxpath){ea=window.jsxpath;} -else{var fa=document.getElementsByTagName('script');var ga=fa[fa.length-1];var ha=ga.src;ea={};var ia=ha.match(/\?(.*)$/);if(ia){var ja=ia[1].split('&');for(var i=0,l=ja.length;i=0){this.opera=true;} -else if(ua.indexOf("Netscape")>=0){this.netscape=true;} -else if(ua.indexOf("Mozilla/")==0){this.mozilla=true;} -else{this.unknown=true;} -if(ua.indexOf("Gecko/")>=0){this.gecko=true;} -if(ua.indexOf("Win")>=0){this.windows=true;} -else if(ua.indexOf("Mac")>=0){this.mac=true;} -else if(ua.indexOf("Linux")>=0){this.linux=true;} -else if(ua.indexOf("BSD")>=0){this.bsd=true;} -else if(ua.indexOf("SunOS")>=0){this.sunos=true;}} -else{ /*@cc_on @if(@_jscript)function jscriptVersion(){switch(@_jscript_version){case 3.0:return "4.0";case 5.0:return "5.0";case 5.1:return "5.01";case 5.5:return "5.5";case 5.6:if("XMLHttpRequest" in window)return "7.0";return "6.0";case 5.7:return "7.0";default:return true;}} -if(@_win16||@_win32||@_win64){this.windows=true;this.trident=jscriptVersion();} -else if(@_mac||navigator.platform.indexOf("Mac")>=0){this.mac=true;this.tasman=jscriptVersion();} -if(/MSIE (\d+\.\d+)b?;/.test(ua)){this.ie=RegExp.$1;this['ie'+RegExp.$1.charAt(0)]=true;}@else @*/ -if(/AppleWebKit\/(\d+(?:\.\d+)*)/.test(ua)){this.applewebkit=RegExp.$1;if(RegExp.$1.charAt(0)==4){this.applewebkit2=true;} -else{this.applewebkit3=true;}} -else if(typeof Components=="object"&&(/Gecko\/(\d{8})/.test(ua)||navigator.product=="Gecko"&&/^(\d{8})$/.test(navigator.productSub))){this.gecko=RegExp.$1;}/*@end @*/ -if(typeof(opera)=="object"&&typeof(opera.version)=="function"){this.opera=opera.version();this['opera'+this.opera[0]+this.opera[2]]=true;} -else if(typeof opera=="object"&&(/Opera[\/ ](\d+\.\d+)/.test(ua))){this.opera=RegExp.$1;} -else if(this.ie){} -else if(/Safari\/(\d+(?:\.\d+)*)/.test(ua)){this.safari=RegExp.$1;} -else if(/NetFront\/(\d+(?:\.\d+)*)/.test(ua)){this.netfront=RegExp.$1;} -else if(/Konqueror\/(\d+(?:\.\d+)*)/.test(ua)){this.konqueror=RegExp.$1;} -else if(ua.indexOf("(compatible;")<0&&(/^Mozilla\/(\d+\.\d+)/.test(ua))){this.mozilla=RegExp.$1;if(/\([^(]*rv:(\d+(?:\.\d+)*).*?\)/.test(ua))this.mozillarv=RegExp.$1;if(/Firefox\/(\d+(?:\.\d+)*)/.test(ua)){this.firefox=RegExp.$1;} -else if(/Netscape\d?\/(\d+(?:\.\d+)*)/.test(ua)){this.netscape=RegExp.$1;}} -else{this.unknown=true;} -if(ua.indexOf("Win 9x 4.90")>=0){this.windows="ME";} -else if(/Win(?:dows)? ?(NT ?(\d+\.\d+)?|\d+|ME|Vista|XP)/.test(ua)){this.windows=RegExp.$1;if(RegExp.$2){this.winnt=RegExp.$2;} -else switch(RegExp.$1){case "2000":this.winnt="5.0";break;case "XP":this.winnt="5.1";break;case "Vista":this.winnt="6.0";break;}} -else if(ua.indexOf("Mac")>=0){this.mac=true;} -else if(ua.indexOf("Linux")>=0){this.linux=true;} -else if(/(\w*BSD)/.test(ua)){this.bsd=RegExp.$1;} -else if(ua.indexOf("SunOS")>=0){this.sunos=true;}}};var Ea=function(Fa){var Ga=Ea.prototype;var Ha=Fa.match(Ga.regs.token);for(var i=0,l=Ha.length;i]=|(?![0-9-])[\w-]+:\*|\s+|./g,strip:/^\s/};Ea.prototype.peek=function(i){return this[this.index+(i||0)];};Ea.prototype.next=function(){return this[this.index++];};Ea.prototype.back=function(){this.index--;};Ea.prototype.empty=function(){return this.length<=this.index;};var Ia=function(Ja,Ka,La){this.node=Ja;this.position=Ka||1;this.last=La||1;};var Ma=function(){};Ma.prototype.number=function(Na){var Oa=this.evaluate(Na);if(Oa.isNodeSet)return Oa.number();return+Oa;};Ma.prototype.string=function(Pa){var Qa=this.evaluate(Pa);if(Qa.isNodeSet)return Qa.string();return ''+Qa;};Ma.prototype.bool=function(Ra){var Sa=this.evaluate(Ra);if(Sa.isNodeSet)return Sa.bool();return!!Sa;};var Ta=function(){};Ta.parsePredicates=function(Ua,Va){while(Ua.peek()=='['){Ua.next();if(Ua.empty()){throw Error('missing predicate expr');} -var Wa=oa.parse(Ua);Va.predicate(Wa);if(Ua.empty()){throw Error('unclosed predicate expr');} -if(Ua.next()!=']'){Ua.back();throw Error('bad token: '+Ua.next());}}};Ta.prototype=new Ma();Ta.prototype.evaluatePredicates=function(Xa,Ya){var Za,predicate,nodes,node,Xa,position,reverse;reverse=this.reverse;Za=this.predicates;Xa.sort();for(var i=Ya||0,l0=Za.length;i=l1;j--){Xa.del($a[j]);}} -return Xa;};if(!window.BinaryExpr&&window.defaultConfig)window.BinaryExpr=null;oa=function(op,bb,cb,db){this.op=op;this.left=bb;this.right=cb;this.datatype=oa.ops[op][2];this.needContextPosition=bb.needContextPosition||cb.needContextPosition;this.needContextNode=bb.needContextNode||cb.needContextNode;if(this.op=='='){if(!cb.needContextNode&&!cb.needContextPosition&&cb.datatype!='nodeset'&&cb.datatype!='void'&&bb.quickAttr){this.quickAttr=true;this.attrName=bb.attrName;this.attrValueExpr=cb;} -else if(!bb.needContextNode&&!bb.needContextPosition&&bb.datatype!='nodeset'&&bb.datatype!='void'&&cb.quickAttr){this.quickAttr=true;this.attrName=cb.attrName;this.attrValueExpr=bb;}}};oa.compare=function(op,eb,fb,gb,hb){var ib,lnodes,rnodes,nodes,nodeset,primitive;fb=fb.evaluate(hb);gb=gb.evaluate(hb);if(fb.isNodeSet&&gb.isNodeSet){lnodes=fb.list();rnodes=gb.list();for(var i=0,l0=lnodes.length;i':[4,function(Bb,Cb,Db){return oa.compare('>',function(a,b){return a>b},Bb,Cb,Db);},'boolean'],'<=':[4,function(Eb,Fb,Gb){return oa.compare('<=',function(a,b){return a<=b},Eb,Fb,Gb);},'boolean'],'>=':[4,function(Hb,Ib,Jb){return oa.compare('>=',function(a,b){return a>=b},Hb,Ib,Jb);},'boolean'],'=':[3,function(Kb,Lb,Mb){return oa.compare('=',function(a,b){return a==b},Kb,Lb,Mb);},'boolean'],'!=':[3,function(Nb,Ob,Pb){return oa.compare('!=',function(a,b){return a!=b},Nb,Ob,Pb);},'boolean'],'and':[2,function(Qb,Rb,Sb){return Qb.bool(Sb)&&Rb.bool(Sb);},'boolean'],'or':[1,function(Tb,Ub,Vb){return Tb.bool(Vb)||Ub.bool(Vb);},'boolean']};oa.parse=function(Wb){var op,precedence,info,expr,stack=[],index=Wb.index;while(true){if(Wb.empty()){throw Error('missing right expression');} -expr=Aa.parse(Wb);op=Wb.next();if(!op){break;} -info=this.ops[op];precedence=info&&info[0];if(!precedence){Wb.back();break;} -while(stack.length&&precedence<=this.ops[stack[stack.length-1]][0]){expr=new oa(stack.pop(),stack.pop(),expr);} -stack.push(expr,op);} -while(stack.length){expr=new oa(stack.pop(),stack.pop(),expr);} -return expr;};oa.prototype=new Ma();oa.prototype.evaluate=function(Xb){return oa.ops[this.op][1](this.left,this.right,Xb);};oa.prototype.show=function(Yb){Yb=Yb||'';var t='';t+=Yb+'binary: '+this.op+'\n';Yb+=' ';t+=this.left.show(Yb);t+=this.right.show(Yb);return t;};if(!window.UnaryExpr&&window.defaultConfig)window.UnaryExpr=null;Aa=function(op,Zb){this.op=op;this.expr=Zb;this.needContextPosition=Zb.needContextPosition;this.needContextNode=Zb.needContextNode;};Aa.ops={'-':1};Aa.parse=function($b){var ac;if(this.ops[$b.peek()])return new Aa($b.next(),Aa.parse($b));else return Ba.parse($b);};Aa.prototype=new Ma();Aa.prototype.datatype='number';Aa.prototype.evaluate=function(bc){return-this.expr.number(bc);};Aa.prototype.show=function(cc){cc=cc||'';var t='';t+=cc+'unary: '+this.op+'\n';cc+=' ';t+=this.expr.show(cc);return t;};if(!window.UnionExpr&&window.defaultConfig)window.UnionExpr=null;Ba=function(){this.paths=[];};Ba.ops={'|':1};Ba.parse=function(dc){var ec,expr;expr=ya.parse(dc);if(!this.ops[dc.peek()])return expr;ec=new Ba();ec.path(expr);while(true){if(!this.ops[dc.next()])break;if(dc.empty()){throw Error('missing next union location path');} -ec.path(ya.parse(dc));} -dc.back();return ec;};Ba.prototype=new Ma();Ba.prototype.datatype='nodeset';Ba.prototype.evaluate=function(fc){var gc=this.paths;var hc=new ta();for(var i=0,l=gc.length;ideep2){while(deep1--!=deep2)gf=gf.parentNode;if(gf==node2)return 1;} -else if(deep2>deep1){while(deep2--!=deep1)node2=node2.parentNode;if(gf==node2)return -1;} -while((ancestor1=gf.parentNode)!=(ancestor2=node2.parentNode)){gf=ancestor1;node2=ancestor2;} -while(gf=gf.nextSibling)if(gf==node2)return -1;return 1;}});}}; /*@cc_on @if(@_jscript)ta.prototype.sourceOffset=1;ta.prototype.subOffset=2;ta.prototype.createWrapper=function(hf){var jf,child,attributes,attributesLength,sourceIndex,subIndex,attributeName;sourceIndex=hf.sourceIndex;if(typeof sourceIndex!='number'){type=hf.nodeType;switch(type){case 2:jf=hf.parentNode;sourceIndex=hf.parentSourceIndex;subIndex=-1;attributeName=hf.nodeName;break;case 9:subIndex=-2;sourceIndex=-1;break;default:child=hf;subIndex=0;do{subIndex++;sourceIndex=child.sourceIndex;if(sourceIndex){jf=child;child=child.lastChild;if(!child){child=jf;break;} -subIndex++;}} -while(child=child.previousSibling);if(!sourceIndex){sourceIndex=hf.parentNode.sourceIndex;} -break;}} -else{subIndex=-2;} -sourceIndex+=this.sourceOffset;subIndex+=this.subOffset;return new Ue(hf,sourceIndex,subIndex,attributeName);};ta.prototype.reserveDelBySourceIndexAndSubIndex=function(kf,lf,mf,nf){var of=this.createIdIndexMap();var pf;if((of=of[kf])&&(pf=of[lf])){if(nf&&(this.length-mf-1)>pf||!nf&&mfuf||!sf&&rf=0x10000||subIndex>=0x10000){this.shortcut=false;} -if(this._first||this.nodes.length==0){Pf=this._first;firstSourceIndex=this._firstSourceIndex;firstSubIndex=this._firstSubIndex;if(!Pf||firstSourceIndex>sourceIndex||(firstSourceIndex==sourceIndex&&firstSubIndex>subIndex)){this._first=Nf;this._firstSourceIndex=sourceIndex;this._firstSubIndex=subIndex}}@else @*/ -var Qf=this.seen;var id=Ze.get(Nf);if(Qf[id])return true;Qf[id]=true;/*@end @*/ -this.length++;if(Of)this.nodes.unshift(Nf);else this.nodes.push(Nf);};ta.prototype.unshift=function(Rf){if(!this.length){this.length++;this.only=Rf;return} -if(this.only){var Sf=this.only;delete this.only;this.unshift(Sf);this.length--;} /*@cc_on -Rf=this.createWrapper(Rf);@*/return this._add(Rf,true);};ta.prototype.push=function(Tf){if(!this.length){this.length++;this.only=Tf;return;} -if(this.only){var Uf=this.only;delete this.only;this.push(Uf);this.length--;} /*@cc_on -Tf=this.createWrapper(Tf);@*/return this._add(Tf);};ta.prototype.first=function(){if(this.only)return this.only; /*@cc_on -if(this._first)return this._first.node;if(this.nodes.length>1)this.sort();var Vf=this.nodes[0];return Vf?Vf.node:ca;@*/if(this.nodes.length>1)this.sort();return this.nodes[0];};ta.prototype.list=function(){if(this.only)return[this.only];this.sort(); /*@cc_on -var i,l,Mf,results;Mf=this.nodes;results=[];for(i=0,l=Mf.length;i Date: Mon, 18 Nov 2013 15:27:28 +0100 Subject: [PATCH 43/52] remove useless build specs --- project.clj | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/project.clj b/project.clj index 4910e71..e753fd4 100644 --- a/project.clj +++ b/project.clj @@ -5,9 +5,5 @@ [org.clojure/clojurescript "0.0-2030"]] :plugins [[lein-cljsbuild "1.0.0-alpha2"]] :hooks [leiningen.cljsbuild] - :cljsbuild {:builds {:deploy - {:source-paths ["src/cljs"] - :compiler {:libs ["goog/dom/query.js"] - :pretty-print true - :output-dir ".cljsbuild/domina" - :output-to "public/domina.js"}}}}) + :cljsbuild {:builds {:useless + {:source-paths ["src/cljs"]}}}) From 8e321fa550ebf39960e71cc6359105d76fbcd978 Mon Sep 17 00:00:00 2001 From: Mimmmo Cosenza Date: Mon, 18 Nov 2013 15:28:25 +0100 Subject: [PATCH 44/52] add brepl help text --- dev-resources/public/index.html | 43 +++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/dev-resources/public/index.html b/dev-resources/public/index.html index 7d12fac..a98e999 100644 --- a/dev-resources/public/index.html +++ b/dev-resources/public/index.html @@ -1,14 +1,43 @@ - + bREPL Connection + + - - - - + + +

BREPL connection

+

Running the brepl

+
    +
  1. cd to + $DOMINA, and run: +
    $ lein do compile, repl
    This will compile the domina cljs code. +
  2. Once you're in the REPL (it will start up in the + domina.server namespace), evaluate + (run). That just starts jetty on port + 8080; if you open a browser to + that server, you'll + see this page. +
  3. +
  4. Create a new Austin ClojureScript REPL environment, + like so: +
    (def repl-env (reset! cemerick.austin.repls/browser-repl-env
    +          (cemerick.austin/repl-env)))
    +        
    +
  5. +
  6. Turn your Clojure REPL into a ClojureScript REPL + tied to that REPL environment with +
    (cemerick.austin.repls/cljs-repl repl-env)
  7. +
  8. Now that the ClojureScript REPL is ready, you need to load + http://localhost:8080, or + reload it if you brought it up before the REPL environment was + created. Once you do that, evaluate some ClojureScript to make + sure your shiny new REPL is working, e.g. +
    (js/alert "Hello, Domina!")
    +
  9. +
+ From 9f8ab58ea5003caed735932e59f0da69c3e3a955 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Tue, 26 Nov 2013 08:33:03 +0100 Subject: [PATCH 45/52] update lein-cljsbuild to 1.0.0 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index e753fd4..9ee922a 100644 --- a/project.clj +++ b/project.clj @@ -3,7 +3,7 @@ :source-paths ["src/clj" "src/cljs"] :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojurescript "0.0-2030"]] - :plugins [[lein-cljsbuild "1.0.0-alpha2"]] + :plugins [[lein-cljsbuild "1.0.0"]] :hooks [leiningen.cljsbuild] :cljsbuild {:builds {:useless {:source-paths ["src/cljs"]}}}) From 984b5ddc5d42f502544f3a6505bb00917ea59700 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Tue, 26 Nov 2013 08:34:01 +0100 Subject: [PATCH 46/52] update clojurescript.test to 0.2.1 --- profiles.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles.clj b/profiles.clj index fa498d0..a36fc00 100644 --- a/profiles.clj +++ b/profiles.clj @@ -4,7 +4,7 @@ [ring "1.2.1"] [compojure "1.1.6"] [enlive "1.1.4"]] - :plugins [[com.cemerick/clojurescript.test "0.2.0"] + :plugins [[com.cemerick/clojurescript.test "0.2.1"] [com.cemerick/austin "0.1.3"]] :cljsbuild {:builds {#_:none #_{:source-paths ["src/cljs" "test/cljs"] From 4a3b7ce26f34f110e292d549ec19a71554c36cc8 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Tue, 26 Nov 2013 09:38:58 +0100 Subject: [PATCH 47/52] add injections to simplify the brepl connection --- profiles.clj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/profiles.clj b/profiles.clj index a36fc00..15b25e9 100644 --- a/profiles.clj +++ b/profiles.clj @@ -38,4 +38,8 @@ #_"advanced" #_["phantomjs" :runner "dev-resources/public/js/advanced.js"]}} - :repl-options {:init-ns domina.server}}} + :injections [(require '[ring.server :as http :refer [run]] + 'cemerick.austin.repls) + (defn browser-repl [] + (cemerick.austin.repls/cljs-repl (reset! cemerick.austin.repls/browser-repl-env + (cemerick.austin/repl-env))))]}} From 0feb250d087e1b3b434a149abe90dd5d1f3f1ff6 Mon Sep 17 00:00:00 2001 From: magomimmo Date: Tue, 26 Nov 2013 09:40:25 +0100 Subject: [PATCH 48/52] rename domina.server to ring.server --- dev-resources/clj/{domina => ring}/server.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename dev-resources/clj/{domina => ring}/server.clj (97%) diff --git a/dev-resources/clj/domina/server.clj b/dev-resources/clj/ring/server.clj similarity index 97% rename from dev-resources/clj/domina/server.clj rename to dev-resources/clj/ring/server.clj index 3ed2771..948e2ab 100644 --- a/dev-resources/clj/domina/server.clj +++ b/dev-resources/clj/ring/server.clj @@ -1,4 +1,4 @@ -(ns domina.server +(ns ring.server (:require [cemerick.austin.repls :refer (browser-connected-repl-js)] [net.cgrand.enlive-html :as enlive] [compojure.route :refer (resources)] From d775282dcb97047c10dddc57a3ab93daf89cf8ef Mon Sep 17 00:00:00 2001 From: magomimmo Date: Tue, 26 Nov 2013 09:41:09 +0100 Subject: [PATCH 49/52] update index.html --- dev-resources/public/index.html | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/dev-resources/public/index.html b/dev-resources/public/index.html index a98e999..ee6d793 100644 --- a/dev-resources/public/index.html +++ b/dev-resources/public/index.html @@ -15,22 +15,15 @@

Running the brepl

  • cd to $DOMINA, and run:
    $ lein do compile, repl
    This will compile the domina cljs code. -
  • Once you're in the REPL (it will start up in the - domina.server namespace), evaluate +
  • Once you're in the REPL evaluate (run). That just starts jetty on port 8080; if you open a browser to that server, you'll see this page.
  • -
  • Create a new Austin ClojureScript REPL environment, - like so: -
    (def repl-env (reset! cemerick.austin.repls/browser-repl-env
    -          (cemerick.austin/repl-env)))
    -        
    +
  • Activate the browser-connected REPL like so: +
    (browser-repl)
  • -
  • Turn your Clojure REPL into a ClojureScript REPL - tied to that REPL environment with -
    (cemerick.austin.repls/cljs-repl repl-env)
  • Now that the ClojureScript REPL is ready, you need to load http://localhost:8080, or reload it if you brought it up before the REPL environment was From 571e62a9c7431a4f21ae86b4d3ca635e9d1b9647 Mon Sep 17 00:00:00 2001 From: Mimmo Cosenza Date: Tue, 20 Oct 2015 22:34:52 +0200 Subject: [PATCH 50/52] clj=1.7.0, cljs=0.0-3308, cljsbuild=1.1.0 and added clean-targets --- project.clj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/project.clj b/project.clj index 9ee922a..e84f7f0 100644 --- a/project.clj +++ b/project.clj @@ -1,9 +1,10 @@ (defproject domina "1.0.3-SNAPSHOT" :description "A DOM manipulation library for ClojureScript inspired by JQuery" :source-paths ["src/clj" "src/cljs"] - :dependencies [[org.clojure/clojure "1.5.1"] - [org.clojure/clojurescript "0.0-2030"]] - :plugins [[lein-cljsbuild "1.0.0"]] + :dependencies [[org.clojure/clojure "1.7.0"] + [org.clojure/clojurescript "0.0-3308"]] + :plugins [[lein-cljsbuild "1.1.0"]] :hooks [leiningen.cljsbuild] :cljsbuild {:builds {:useless - {:source-paths ["src/cljs"]}}}) + {:source-paths ["src/cljs"]}}} + :clean-targets ^{:protect false} ["dev-resources/public/js" :target-path]) From f7a0f80734e12dad8a8dc2e2ebe6a5beac8aec2b Mon Sep 17 00:00:00 2001 From: Mimmo Cosenza Date: Tue, 20 Oct 2015 22:36:39 +0200 Subject: [PATCH 51/52] move domina.cljs to core.cljs --- src/cljs/domina/core.cljs | 558 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 558 insertions(+) create mode 100644 src/cljs/domina/core.cljs diff --git a/src/cljs/domina/core.cljs b/src/cljs/domina/core.cljs new file mode 100644 index 0000000..474d2ca --- /dev/null +++ b/src/cljs/domina/core.cljs @@ -0,0 +1,558 @@ +(ns domina.core + (:refer-clojure :exclude [clone]) + (:require + [goog.dom :as dom] + [goog.dom.xml :as xml] + [goog.dom.classes :as classes] + [goog.dom.forms :as forms] + [goog.events :as events] + [goog.style :as style] + [goog.string :as string] + [cljs.core :as core] + [clojure.string :as cstring] + [domina.support :as support]) + (:require-macros [domina.macros :as dm])) + +;;;;;;;;;;;;;;;;;;; Parse HTML to DOM ;; + +(def re-html #"<|&#?\w+;") +(def re-leading-whitespace #"^\s+") +(def re-xhtml-tag #"(?i)<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)/>") +(def re-tag-name #"<([\w:]+)") +(def re-no-inner-html #"(?i)<(?:script|style)") +(def re-tbody #"(?i)" ""] + table-section-wrapper [1 "" "
    "] + cell-wrapper [3 "" "
    "]] + (def wrap-map {"option" opt-wrapper + "optgroup" opt-wrapper + "legend" [ 1 "
    " "
    " ] + "thead" table-section-wrapper + "tbody" table-section-wrapper + "tfoot" table-section-wrapper + "colgroup" table-section-wrapper + "caption" table-section-wrapper + "tr" [ 2 "" "
    " ] + "td" cell-wrapper + "th" cell-wrapper + "col" [ 2 "" "
    " ] + "area" [ 1 "" "" ] + :default [ 0 "" "" ]})) ;; TODO IE can't serialize and