Permalink
Browse files

BUG Rewrite hashlinks failing on empty a tags

Check for presence of href in _a_ tags before trying to .match them to
prevent null pointer errors.

Some external JS libs (eg tag-it) use <ul><a> structures which get matched
and break

(fixes regression introduced by ff39f9a)
  • Loading branch information...
1 parent 9106e41 commit 34788130ef52c93eda81c62aab3fc0c869f68025 @nyeholt nyeholt committed Dec 4, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 admin/javascript/LeftAndMain.js
@@ -951,6 +951,7 @@ jQuery.noConflict();
*/
rewriteHashlinks: function() {
$(this).find('ul a').each(function() {
+ if (!$(this).attr('href')) return;
var matches = $(this).attr('href').match(/#.*/);
if(!matches) return;
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);

0 comments on commit 3478813

Please sign in to comment.