From 1a60337c22bc70e65519850cdb17b96fde550e8d Mon Sep 17 00:00:00 2001 From: Chris Broadfoot Date: Fri, 3 Feb 2017 19:16:49 -0800 Subject: [PATCH] godoc/static: clean up the expandos code that handles the hash Change-Id: I14e6777f781253a574f76c7d8a345d248b5a4306 Reviewed-on: https://go-review.googlesource.com/36320 Reviewed-by: Russ Cox --- godoc/static/godocs.js | 10 ++++++++-- godoc/static/static.go | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/godoc/static/godocs.js b/godoc/static/godocs.js index 23a580e5..5177c302 100644 --- a/godoc/static/godocs.js +++ b/godoc/static/godocs.js @@ -245,9 +245,15 @@ function fixFocus() { } function toggleHash() { + var id = window.location.hash.substring(1); // Open all of the toggles for a particular hash. - var els = $(document.getElementById(window.location.hash.substring(1)), - $.find("a[name='" + window.location.hash.substring(1) + "']")); + var els = $( + document.getElementById(id), + $('a[name]').filter(function() { + return $(this).attr('name') == id; + }) + ); + while (els.length) { for (var i = 0; i < els.length; i++) { var el = $(els[i]); diff --git a/godoc/static/static.go b/godoc/static/static.go index 6fab8da3..2d478afc 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -815,9 +815,15 @@ function fixFocus() { } function toggleHash() { + var id = window.location.hash.substring(1); // Open all of the toggles for a particular hash. - var els = $(document.getElementById(window.location.hash.substring(1)), - $("a[name='" + window.location.hash.substring(1) + "']")); + var els = $( + document.getElementById(id), + $('a[name]').filter(function() { + return $(this).attr('name') == id; + }) + ); + while (els.length) { for (var i = 0; i < els.length; i++) { var el = $(els[i]);