Skip to content

Commit 75c0970

Browse files
committed
Remove jQuery from hashchange.js
It doesn't work under Fastboot
1 parent 0a67403 commit 75c0970

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/initializers/hashchange.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import $ from 'jquery';
2-
31
function decodeFragmentValue(hash) {
42
try {
53
return decodeURIComponent(hash.slice(1));
@@ -29,11 +27,17 @@ function hashchange() {
2927
}
3028

3129
export function initialize() {
32-
$(window).on('hashchange', hashchange);
30+
if (typeof window.addEventListener === 'undefined') {
31+
return; // Fastboot
32+
}
33+
window.addEventListener('hashchange', hashchange);
3334

3435
// If clicking on a link to the same fragment as currently in the address bar,
3536
// hashchange won't be fired, so we need to manually trigger rescroll.
36-
$(document).on('a[href]', 'click', function(event) {
37+
document.addEventListener('click', function(event) {
38+
if (event.target.tagName !== 'A') {
39+
return;
40+
}
3741
if (this.href === location.href && location.hash.length > 1) {
3842
setTimeout(function() {
3943
if (!event.defaultPrevented) {

0 commit comments

Comments
 (0)