scrollspy can't handle href attributes that don't start with #
Created by: mindw0rm
Scrollspy won't work if the href attributes in the assigned target start with the current URI (e.g. href="/path/to/some.html#some-id").
This can be fixed by small changes in Scrollspy.prototype.refresh and Scrollspy.prototype.active:
ScrollSpy.prototype.refresh = function () {
[...]
var href = $el.data('target') || $el.attr('href')
/*fix part 1 (line 52 in v3.0.3): remove URI prefix if present */
if (href[0] != '#') href = '#'+href.split('#')[1]
/***/
var $href = /^#./.test(href) && $(href)
[...]
}
ScrollSpy.prototype.activate = function (target) {
[...]
var selector = this.selector +
'[data-target="' + target + '"],' +
/* fix part 2 (line 101 in v3.0.3): use href$= instead of href= */
this.selector + '[href$="' + target + '"]'
[...]
}```