summaryrefslogtreecommitdiff
path: root/lisp/dom.el
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen <larsi@gnus.org>2014-11-26 22:08:44 +0100
committerLars Magne Ingebrigtsen <larsi@gnus.org>2014-11-26 22:08:52 +0100
commit7520f8919ae4030b5b2c3fbcc4141c85bb65aad1 (patch)
tree0e672a0fe7097a140e4960e962713be79e144043 /lisp/dom.el
parentc9cb3d535b2daf19b53dcaeedc2f2ae923bca2a1 (diff)
downloademacs-7520f8919ae4030b5b2c3fbcc4141c85bb65aad1.tar.gz
Further eww dom.el cleanups
* net/eww.el (eww-tag-title): Use `dom-text'. * dom.el (dom-by-tag): Use `equal' for comparisons so that tags can be strings. (dom-elements): Protect against non-text nodes. (dom-non-text-children): New function.
Diffstat (limited to 'lisp/dom.el')
-rw-r--r--lisp/dom.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/dom.el b/lisp/dom.el
index 3157e0b2f2a..04d6c219ec0 100644
--- a/lisp/dom.el
+++ b/lisp/dom.el
@@ -47,6 +47,12 @@
(cddr (car node))
(cddr node)))
+(defun dom-non-text-children (node)
+ "Return all non-text-node children of NODE."
+ (cl-loop for child in (dom-children node)
+ unless (stringp child)
+ collect child))
+
(defun dom-set-attributes (node attributes)
"Set the attributes of NODE to ATTRIBUTES."
(setq node (dom-ensure-node node))
@@ -93,7 +99,7 @@ A name is a symbol like `td'."
(dom-by-tag child tag))
when matches
append matches)))
- (if (eq (dom-tag dom) tag)
+ (if (equal (dom-tag dom) tag)
(cons dom matches)
matches)))
@@ -113,7 +119,9 @@ A name is a symbol like `td'."
"Find elements matching MATCH (a regexp) in ATTRIBUTE.
ATTRIBUTE would typically be `class', `id' or the like."
(let ((matches (cl-loop for child in (dom-children dom)
- for matches = (dom-elements child attribute match)
+ for matches = (and (not (stringp child))
+ (dom-elements child attribute
+ match))
when matches
append matches))
(attr (dom-attr dom attribute)))