mirror of
https://github.com/golang/go
synced 2024-11-18 12:14:42 -07:00
godoc: fix bug in "internal call graph" tree widget.
Today I learned that getElementByClass returns an HTMLContainer, not an array, so the for loop was iterating its properties, which include: - the methods of the type, which were filtered out by the condition; - the array-like integer indices of the elements, which we want; - the ids of the same elements (!), which we weren't expecting. The net result is that various functions were called twice, causing the tree to be double-populated and clicks to cause and expand+collapse. It's a miracle to me that any JS program even approximately works. Fixes golang/go#8237 LGTM=bradfitz R=gri, bradfitz CC=golang-codereviews https://golang.org/cl/141540043
This commit is contained in:
parent
1bd4ccf210
commit
ebc87c5c5e
@ -441,7 +441,7 @@ function setupCallgraphs() {
|
||||
document.getElementById("pkg-callgraph").style.display = "block";
|
||||
|
||||
var treeviews = document.getElementsByClassName("treeview");
|
||||
for (var i in treeviews) {
|
||||
for (var i = 0; i < treeviews.length; i++) {
|
||||
var tree = treeviews[i];
|
||||
if (tree.id == null || tree.id.indexOf("callgraph-") != 0) {
|
||||
continue;
|
||||
|
@ -1014,6 +1014,7 @@ function setupCallgraphs() {
|
||||
document.getElementById("pkg-callgraph").style.display = "block";
|
||||
|
||||
var treeviews = document.getElementsByClassName("treeview");
|
||||
// for (var i = 0; i < treeviews.length; i++) {
|
||||
for (var i in treeviews) {
|
||||
var tree = treeviews[i];
|
||||
if (tree.id == null || tree.id.indexOf("callgraph-") != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user