Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Consistent handling of extra attr argument in (append).

  • Loading branch information...
commit 6fcbff458bec1e6365a42bc6a1303584e2194153 1 parent 924308e
@lynaghk lynaghk authored
Showing with 19 additions and 17 deletions.
  1. +19 −17 src/cljs/cljs_d3/core.cljs
View
36 src/cljs/cljs_d3/core.cljs
@@ -80,23 +80,25 @@
If passed :svg, call .append('svg:svg'), and also add namespace declarations so the resulting element is also valid XML.
Automatically make nodes take on the namespace of the first element in the selection (this may be removed if Mike incorporates this feature into D3 itself; see D3 issue #272)."
;;Handle some special cases
- (condp = node-type
- :svg (append-svg sel)
- ;;else
- (let [[namespace nt] (cond
- ;;user-specified namespace
- (re-find #":" node-type) (s/split node-type #":" 2)
-
- ;;inhert parent element namespaceURI; this only works on simple (append)s, not on, say, (enter) selections.
- (.node sel) [(ns-abbv (.namespaceURI (. sel (node)))) node-type]
-
- ;;no namespace found...
- true [nil node-type])
- sel (.append sel (if (nil? namespace)
- nt
- (str (name namespace) ":" nt)))]
-
- (attr sel (or attr-map {})))))
+ (let [new-el (condp = node-type
+ :svg (append-svg sel)
+ ;;else
+ (let [[namespace nt] (cond
+ ;;user-specified namespace
+ (re-find #":" node-type) (s/split node-type #":" 2)
+
+ ;;inhert parent element namespaceURI; this only works on simple (append)s, not on, say, (enter) selections.
+ (.node sel) [(ns-abbv (.namespaceURI (. sel (node)))) node-type]
+
+ ;;no namespace found...
+ true [nil node-type])]
+ (.append sel (if (nil? namespace)
+ nt
+ (str (name namespace) ":" nt)))
+
+ ))]
+ ;;Apply attr-map, if it was given
+ (attr new-el (or attr-map {}))))
(defn append-svg [sel]
;;See SVG authoring guidelines for more info: https://jwatt.org/svg/authoring/
Please sign in to comment.
Something went wrong with that request. Please try again.