diff options
author | Chouser <chouser@n01se.net> | 2008-04-10 23:44:41 +0000 |
---|---|---|
committer | Chouser <chouser@n01se.net> | 2008-04-10 23:44:41 +0000 |
commit | ca68d8d9a2434dee67aaeaffd245e383b82e6e6d (patch) | |
tree | c14766e43ecb6a363d377058d8d14d906ad220ce | |
parent | bc1168f898e80815f10507c7c48736100c3fd21d (diff) |
Catch a couple error conditions.
-rw-r--r-- | zip-filter.clj | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/zip-filter.clj b/zip-filter.clj index 976f4d06..12c873cb 100644 --- a/zip-filter.clj +++ b/zip-filter.clj @@ -72,7 +72,7 @@ #^{:private true} [pred loc] (let [rtn (pred loc)] - (cond (:zip-filter/is-node? ^rtn) (list rtn) + (cond (and (map? ^rtn) (:zip-filter/is-node? ^rtn)) (list rtn) (= rtn true) (list loc) (= rtn false) nil (nil? rtn) nil @@ -83,7 +83,7 @@ #^{:private true} [loc preds mkpred] (reduce (fn [prevseq expr] - (mapcat (partial fixup-apply (or (mkpred expr) expr)) prevseq)) + (mapcat #(fixup-apply (or (mkpred expr) expr) %) prevseq)) (list (with-meta loc (assoc ^loc :zip-filter/is-node? true))) preds)) @@ -99,7 +99,7 @@ (defn attr "Returns the xml attribute named attrname, of the xml node at location loc." ([attrname] (fn [loc] (attr loc attrname))) - ([loc attrname] (-> loc zip/node :attrs attrname))) + ([loc attrname] (when (zip/branch? loc) (-> loc zip/node :attrs attrname)))) (defn attr= "Returns a query predicate that matches a node when it has an |