]> git.eshelyaron.com Git - emacs.git/commitdiff
When navigating to anchor targets in EWW, retain 'eww-data' properties
authorJim Porter <jporterbugs@gmail.com>
Sat, 21 Jun 2025 19:10:59 +0000 (12:10 -0700)
committerEshel Yaron <me@eshelyaron.com>
Tue, 24 Jun 2025 06:31:03 +0000 (08:31 +0200)
Previously, navigating to an in-page anchor target would clear
'eww-data', removing many important properties like the original source
and the DOM.  Among other things, this prevented enabling/disabling
readable mode.

* lisp/net/eww.el (eww-follow-link): Copy previous 'eww-data'.

(cherry picked from commit e5ad9ae10090ab34a4d71139e6f928c11f0c029c)

lisp/net/eww.el

index 34f58fd89f0a90f745b8bec4680c1c12965eafa7..c848af1cac4019671fb8c7091d4e9afefb9c1ad0 100644 (file)
@@ -2176,9 +2176,13 @@ EXTERNAL is the prefix argument.  If called interactively with
      ;; This is a #target url in the same page as the current one.
      ((and (setq target (url-target (url-generic-parse-url url)))
           (eww-same-page-p url (plist-get eww-data :url)))
-      (let ((point (point)))
+      (let ((old-data eww-data)
+            (point (point)))
        (eww-save-history)
         (eww--before-browse)
+        ;; Copy previous `eww-data', since everything but the URL will
+        ;; stay the same, and we don't re-render the document.
+        (setq eww-data (copy-sequence old-data))
        (plist-put eww-data :url url)
         (goto-char (point-min))
         (if-let ((match (text-property-search-forward 'shr-target-id target #'member)))