According to the docs, you just need to apply the `navbar-nav` to an
`<ul>` tag in a list-based navbar. In fact, `navbar-nav` seems to
override all the css properties set by `nav`.
Also, `nav-item` class should be used only for `<li>` tags, or in
conjunction with `<a>` tags to entirely avoid the list-based approach.
This commit removes the redundant `nav` class from `navbar-nav` `<ul>`
tags, moves `nav-item` from `<a>` tags to `<li>` tags and properly
adds `nav-item` class to `<li>` tags where missing.
Refs:
* https://v4-alpha.getbootstrap.com/components/navs/
* https://v4-alpha.getbootstrap.com/components/navbar/#nav
When the rubberband effect causes Safari to scroll past the top of the
page, the value of scrollTop becomes negative. If the offset of the first
ScrollSpy target is 0 - essentially if the target is at the top of the
page - then ScrollSpy should not clear the active item. Conceptually, the
first item should remain active when rubberbanding past the top of the
page.
This commit fixes issue #21055 by verifying the first scrollspy target is
not at the top of the page before clearing the active nav-item.
* Use $.one() instead of $.on() since there are no $.off()s in the code.
* Remove unnecessary namespacing of listeners for the `scroll` & `load` events.
These are vanilla DOM events (not custom jQuery namespaced events)
and we're not using jQuery namespacing to manage these event listeners either (e.g. `$.off()`).
[skip validator]
When the first two elements in a scrollspy content block have a document
offset of zero (i.e. they're hard against the top of the page),
Scrollspy would switch between them on every scroll event.
This could happen, for example, in a system of nested sections:
```
<section id="animals">
<section id="dogs">
Content
</section>
</section>
```
This ocurred because Scrollspy's check to see if it's at the end of the
array of sections uses `!arr[index]`. This misses the case where
`arr[index]` does exist and is zero.
This commit explicitly checks the array bounds.