summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/zip.clj15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/clj/clojure/zip.clj b/src/clj/clojure/zip.clj
index 57b3b21b..7423513f 100644
--- a/src/clj/clojure/zip.clj
+++ b/src/clj/clojure/zip.clj
@@ -96,13 +96,14 @@
"Returns the loc of the leftmost child of the node at this loc, or
nil if no children"
[loc]
- (let [[node path] loc
- [c & cnext :as cs] (children loc)]
- (when cs
- (with-meta [c {:l []
- :pnodes (if path (conj (:pnodes path) node) [node])
- :ppath path
- :r cnext}] ^loc))))
+ (when (branch? loc)
+ (let [[node path] loc
+ [c & cnext :as cs] (children loc)]
+ (when cs
+ (with-meta [c {:l []
+ :pnodes (if path (conj (:pnodes path) node) [node])
+ :ppath path
+ :r cnext}] ^loc)))))
(defn up
"Returns the loc of the parent of the node at this loc, or nil if at