emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 254f502 1/2: (dom-texts): Don't return contents of


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 254f502 1/2: (dom-texts): Don't return contents of <script> as text
Date: Thu, 12 Apr 2018 18:14:39 -0400 (EDT)

branch: master
commit 254f5021aa75c161c964bd5f31b957d69814f38f
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    (dom-texts): Don't return contents of <script> as text
    
    From: Lars Ingebrigtsen <address@hidden>
    
    * 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.
---
 lisp/dom.el | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/lisp/dom.el b/lisp/dom.el
index 8750d7f..6045a68 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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]