summaryrefslogtreecommitdiff
path: root/lisp/dom.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2018-04-13 00:11:47 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2018-04-13 00:14:32 +0200
commit254f5021aa75c161c964bd5f31b957d69814f38f (patch)
treed9af7afae790d83f4367ea149ba569c6c9c3e58f /lisp/dom.el
parent3d6fa0b1e085a987588d5b3a54d91abfee42ceea (diff)
downloademacs-254f5021aa75c161c964bd5f31b957d69814f38f.tar.gz
(dom-texts): Don't return contents of <script> as text
From: Lars Ingebrigtsen <larsi@gnus.org> * lisp/dom.el (dom-texts): Don't return contents of <script> as text, because it isn't and makes reasoning about textual parts more difficult.
Diffstat (limited to 'lisp/dom.el')
-rw-r--r--lisp/dom.el24
1 files changed, 15 insertions, 9 deletions
diff --git a/lisp/dom.el b/lisp/dom.el
index 8750d7fa866..6045a68d14c 100644
--- a/lisp/dom.el
+++ b/lisp/dom.el
@@ -78,15 +78,21 @@ A typical attribute is `href'."
(defun dom-texts (node &optional separator)
"Return all textual data under NODE concatenated with SEPARATOR in-between."
- (mapconcat
- 'identity
- (mapcar
- (lambda (elem)
- (if (stringp elem)
- elem
- (dom-texts elem separator)))
- (dom-children node))
- (or separator " ")))
+ (if (eq (dom-tag node) 'script)
+ ""
+ (mapconcat
+ 'identity
+ (mapcar
+ (lambda (elem)
+ (cond
+ ((stringp elem)
+ elem)
+ ((eq (dom-tag elem) 'script)
+ "")
+ (t
+ (dom-texts elem separator))))
+ (dom-children node))
+ (or separator " "))))
(defun dom-child-by-tag (dom tag)
"Return the first child of DOM that is of type TAG."