[issue31668] "fixFirefoxAnchorBug" function in doctools.js causes navigating problem in Py3 doc in Chrome

New submission from fireattack human.peng@gmail.com:
Problem
This is a regression bug/flaw in Sphinx's doctools.js, a JS file used in its base template, and therefore got inherited to Python 3's documentation website. Python 2's documentation website is not affected because it's based on an older version of Sphinx.
There is a function in doctools.js:
/** * workaround a firefox stupidity * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 */ fixFirefoxAnchorBug : function() { if (document.location.hash) window.setTimeout(function() { document.location.href += ''; }, 10); }
This function was supposed to fix an anchor bug in Firefox (see comment). It *used to* have a condition of $.browser outside, so it will only be applied to Firefox; but it was removed in JQuery so it was removed here as well. Therefore, this function now applies to all the browsers. Unfortunately, it causes navigating problem in Chrome now, when you use back and forward.
The problem STR (Chrome only):
1. Open a link with hash (anchor), e.g. https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str 2. Scroll away from the anchor position. 3. Click any external link (means the link that is not an anchor of current page). 4. Hit "back" button in the browser.
What happened:
When you navigating back, it doesn't go to your previous position. Instead, it goes to the anchor's location.
What it should do:
It should go to your previous position.
Ironically, it won't cause this problem in Firefox, despite it's supposed to be a fix for (a different) anchor bug in Firefox.
Comments
I reported it to Sphinx as well: https://github.com/sphinx-doc/sphinx/issues/3549 but didn't get any response so far.
Please keep in mind the Firefox anchor bug mentioned above will only happen if the anchor is assigned with <section id>. From my observation we don't really use <section> in HTML, so I don't think this workaround function is really necessary here to begin with.
---------- assignee: docs@python components: Documentation messages: 303576 nosy: docs@python, fireattack priority: normal severity: normal status: open title: "fixFirefoxAnchorBug" function in doctools.js causes navigating problem in Py3 doc in Chrome type: behavior versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue31668 _______________________________________

Mariatta Wijaya mariatta.wijaya@gmail.com added the comment:
Is there anything to be done in CPython? It appears to be either a bug with the browser or Sphinx...
---------- nosy: +Mariatta
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue31668 _______________________________________

fireattack human.peng@gmail.com added the comment:
Well, since it affects Python's site's functionality, I thought it's appropriate to report here (with components: documentation). I followed the instruction here: https://docs.python.org/3/bugs.html#documentation-bugs
It is not Sphinx's bug per se, since it has nothing to do with its software; just an ancient problematic script in template got copied here.
It is not a Chrome bug, since that script was not intended to apply to Chrome to begin with.
But anyway, if anyone found it's not the right place, feel free to close it.
----------
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue31668 _______________________________________

Berker Peksag berker.peksag@gmail.com added the comment:
This is indeed an annoying bug. Turns out there is already a compatibility shim for $.browser in doctools.js: https://github.com/sphinx-doc/sphinx/commit/c608af4babe140626877be08535af095...
I've opened https://github.com/sphinx-doc/sphinx/pull/4216 to add the "$.browser.firefox" check back.
There is nothing we can do here because we don't maintain a copy of doctools.js in Python codebase:
$ git ls-files | grep doctools.js
Thank you for your report.
---------- nosy: +berker.peksag resolution: -> third party stage: -> resolved status: open -> closed
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue31668 _______________________________________
participants (3)
-
Berker Peksag
-
fireattack
-
Mariatta Wijaya