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 ff39f9ad38)
This commit is contained in:
Marcus Nyeholt 2012-12-04 15:44:13 +11:00
parent 9106e41498
commit 34788130ef

View File

@ -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]);