diff --git a/app/controllers/crate/version.js b/app/controllers/crate/version.js index a0e07e25284..2665eea30cf 100644 --- a/app/controllers/crate/version.js +++ b/app/controllers/crate/version.js @@ -5,7 +5,6 @@ import PromiseProxyMixin from '@ember/object/promise-proxy-mixin'; import ArrayProxy from '@ember/array/proxy'; import { computed, observer } from '@ember/object'; import { later } from '@ember/runloop'; -import $ from 'jquery'; import moment from 'moment'; const NUM_VERSIONS = 5; @@ -185,6 +184,13 @@ export default Controller.extend({ }, report: observer('crate.readme', function() { - setTimeout(() => $(window).trigger('hashchange')); + if (typeof document === 'undefined') { + return; + } + setTimeout(() => { + let e = document.createEvent('CustomEvent'); + e.initCustomEvent('hashchange', true, true); + window.dispatchEvent(e); + }); }), }); diff --git a/app/initializers/hashchange.js b/app/initializers/hashchange.js index f11444cfe63..d852ecf7f0a 100644 --- a/app/initializers/hashchange.js +++ b/app/initializers/hashchange.js @@ -1,5 +1,3 @@ -import $ from 'jquery'; - function decodeFragmentValue(hash) { try { return decodeURIComponent(hash.slice(1)); @@ -29,11 +27,18 @@ function hashchange() { } export function initialize() { - $(window).on('hashchange', hashchange); + if (typeof window === 'undefined' || typeof window.addEventListener === 'undefined') { + // Don't run this initializer under FastBoot + return; + } + window.addEventListener('hashchange', hashchange); // If clicking on a link to the same fragment as currently in the address bar, // hashchange won't be fired, so we need to manually trigger rescroll. - $(document).on('a[href]', 'click', function(event) { + document.addEventListener('click', function(event) { + if (event.target.tagName !== 'A') { + return; + } if (this.href === location.href && location.hash.length > 1) { setTimeout(function() { if (!event.defaultPrevented) {