[openstreetmap/openstreetmap-website] Propagate iD title to parent (PR #5865)
Anton Khorev
notifications at github.com
Sun Mar 30 18:31:16 UTC 2025
@AntonKhorev commented on this pull request.
> @@ -76,5 +76,13 @@ document.addEventListener("DOMContentLoaded", function () {
const data = parent.OSM.mapParams();
goToLocation(data);
});
+
+ const firstParentTitle = parent.document.title;
+ new MutationObserver(function (mutations) {
+ if (!mutations.some(mutation => mutation.target.tagName === "TITLE")) return;
+ const newTitle = `${document.title} | ${firstParentTitle}`;
+ if (parent.document.title === newTitle) return;
+ parent.document.title = newTitle;
+ }).observe(document.head, { childList: true, subtree: true });
You have to observe `document.head` because there's no title element initially. However if you `<title>` to `app/views/site/id.html.erb`, you'll be able to observe it right away. Even an empty title should work.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5865#discussion_r2020224432
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5865/review/2727978151 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250330/73849162/attachment.htm>
More information about the rails-dev
mailing list