* Handles anchor elements with a hash fragment for non-HTML5 browsers * * @param {Event} e
(e)
| 961 | * @param {Event} e |
| 962 | */ |
| 963 | function onAnchorClick(e) { |
| 964 | var event = e || global.event; |
| 965 | var target = anchorTarget(event.target || event.srcElement); |
| 966 | var defaultPrevented = "defaultPrevented" in event ? event['defaultPrevented'] : event.returnValue === false; |
| 967 | if (target && target.nodeName === "A" && !defaultPrevented) { |
| 968 | var current = parseURL(); |
| 969 | var expect = parseURL(target.getAttribute("href", 2)); |
| 970 | var isEqualBaseURL = current._href.split('#').shift() === expect._href.split('#').shift(); |
| 971 | if (isEqualBaseURL && expect._hash) { |
| 972 | if (current._hash !== expect._hash) { |
| 973 | locationObject.hash = expect._hash; |
| 974 | } |
| 975 | scrollToAnchorId(expect._hash); |
| 976 | if (event.preventDefault) { |
| 977 | event.preventDefault(); |
| 978 | } else { |
| 979 | event.returnValue = false; |
| 980 | } |
| 981 | } |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | /** |
| 986 | * Scroll page to current anchor in url-hash |
nothing calls this directly
no test coverage detected