diff --git a/src/modules/hash.js b/src/modules/hash.js index 0bfb5ad7..b162e36f 100644 --- a/src/modules/hash.js +++ b/src/modules/hash.js @@ -38,10 +38,11 @@ export class Hash { } this.lastHash = location.hash; + this.boundSync = this.sync.bind(this); //Store a bound sync wrapper for future use. this.emitter.on(['state-changed'], (tf, state) => this.update(state)); - this.emitter.on(['initialized'], () => this.sync()); - addEvt(root, 'hashchange', () => this.sync()); + this.emitter.on(['initialized'], this.boundSync); + addEvt(root, 'hashchange', this.boundSync); } /** @@ -90,8 +91,8 @@ export class Hash { */ destroy() { this.emitter.off(['state-changed'], (tf, state) => this.update(state)); - this.emitter.off(['initialized'], () => this.sync()); - removeEvt(root, 'hashchange', () => this.sync()); + this.emitter.off(['initialized'], () => this.boundSync); + removeEvt(root, 'hashchange', () => this.boundSync); this.state = null; this.lastHash = null;