Skip to content

Instantly share code, notes, and snippets.

/hash.diff Secret

Created November 3, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5e766dcdfda31574ba47 to your computer and use it in GitHub Desktop.
Save anonymous/5e766dcdfda31574ba47 to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojolicious/resources/templates/mojo/menubar.html.ep b/lib/Mojolicious/resources/templates/mojo/menubar.html.ep
index 26e52bb..b463016 100644
--- a/lib/Mojolicious/resources/templates/mojo/menubar.html.ep
+++ b/lib/Mojolicious/resources/templates/mojo/menubar.html.ep
@@ -128,12 +128,11 @@
$('.mojoscroll').click(function (e) {
e.preventDefault();
e.stopPropagation();
- var anchor = this.href.split('#')[1].replace(/(:|\.|\[|\]|,)/g, "\\$1");
- var hash = '#' + anchor;
- var target = $(hash);
+ var anchor = this.href.split('#')[1];
+ var target = $($(document.getElementById(anchor)));
var old = target.attr('id');
target.attr('id', '');
- location.hash = hash;
+ location.hash = '#' + encodeURIComponent(anchor);
target.attr('id', old);
fixOffset();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment