From: Lars Ingebrigtsen Date: Sat, 23 Jul 2022 05:46:52 +0000 (+0200) Subject: Don't bug out in src when there's no srcset X-Git-Tag: emacs-29.0.90~1447^2~796 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e00f882905db2ac6ffd1ae58b04fa335b38f489c;p=emacs.git Don't bug out in src when there's no srcset * lisp/net/shr.el (shr--preferred-image): Don't bug out when there's no srcset. --- diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 52e4389954a..248faeb223c 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1740,13 +1740,14 @@ BASE is the URL of the HTML being rendered." shr-cookie-policy))) (defun shr--preferred-image (dom) - (let* ((srcset (shr--parse-srcset (dom-attr dom 'srcset) - (and (dom-attr dom 'width) - (string-to-number - (dom-attr dom 'width))))) + (let* ((srcset (and (dom-attr dom 'srcset) + (shr--parse-srcset (dom-attr dom 'srcset) + (and (dom-attr dom 'width) + (string-to-number + (dom-attr dom 'width)))))) (frame-width (frame-pixel-width)) candidate) - (when (length> srcset 0) + (when srcset ;; Choose the smallest picture that's bigger than the current ;; frame. (setq candidate (caar srcset))