1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

When navigating to anchor targets in EWW, retain 'eww-data' properties

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'.
This commit is contained in:
Jim Porter 2025-06-21 12:10:59 -07:00
parent 87fc539a0b
commit e5ad9ae100

View file

@ -2203,9 +2203,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)))