Closed
Bug 1503101
Opened 7 years ago
Closed 7 years ago
Clicking anchor tags with ID as href do nothing
Categories
(developer.mozilla.org Graveyard :: Wiki pages, enhancement)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: urty5656, Assigned: urty5656)
Details
(Whiteboard: [specification][type:bug])
What did you do?
================
1. Go to pages without sticky TOC bar such as https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/panel
2. Click any <a> with ID as its href.
What happened?
==============
(Chrome)
Uncaught TypeError: Cannot read property 'offsetHeight' of null
at Object.scrollToHeading
(Safari)
TypeError: null is not an object (evaluating 'toc.offsetHeight')
What should have happened?
==========================
Jump to an element with the ID.
Is there anything else we should know?
======================================
The code below is from browser source, beautified:
scrollToHeading: function(id) {
"use strict";
var toc = document.getElementById("toc");
if (toc !== undefined) {
this.tocHeight = toc.offsetHeight; // <- Error! toc is null
this.isTocSticky = getComputedStyle(toc).position === "sticky"
}
// ...
},
Without TOC bar, document.getElementById("toc") returns null, not undefined(Chrome 70 / Safari 12).
These would resolve this issue:
if (toc) {
// ...
}
if (toc !== undefined && toc !== null) {
// ...
}
Similar issues found:
https://bugzilla.mozilla.org/show_bug.cgi?id=981838 (wasn't related)
Comment 1•7 years ago
|
||
Commits pushed to master at https://github.com/mozilla/kuma
https://github.com/mozilla/kuma/commit/fb5353baba4358c094973cb7569668dc8ceef766
bug 1503101: Fix hash link without TOC
https://github.com/mozilla/kuma/commit/6472eed398cfce95be57ff18a5ce8372a8f155d1
Merge pull request #5057 from urty5656/1503101
bug 1503101: Fix hash link on pages without TOC
Comment 2•7 years ago
|
||
Thanks for the bug and the fix urty5656. This is deployed to production, fixes the issue.
Assignee: nobody → urty5656
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Updated•5 years ago
|
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•