mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
9106e41498
commit
34788130ef
@ -951,6 +951,7 @@ jQuery.noConflict();
|
|||||||
*/
|
*/
|
||||||
rewriteHashlinks: function() {
|
rewriteHashlinks: function() {
|
||||||
$(this).find('ul a').each(function() {
|
$(this).find('ul a').each(function() {
|
||||||
|
if (!$(this).attr('href')) return;
|
||||||
var matches = $(this).attr('href').match(/#.*/);
|
var matches = $(this).attr('href').match(/#.*/);
|
||||||
if(!matches) return;
|
if(!matches) return;
|
||||||
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
|
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user