Permalink
Browse files

Throw an error if Backbone.history.start is called twice.

  • Loading branch information...
jashkenas committed Feb 7, 2011
1 parent 1944234 commit f1e0f6b5c18f7f347eca6c67767381f77490faee
Showing with 5 additions and 0 deletions.
  1. +5 −0 backbone.js
View
@@ -709,6 +709,9 @@
// Cached regex for cleaning hashes.
var hashStrip = /^#*/;
+ // Has the history handling already been started?
+ var historyStarted = false;
+
// Set up all inheritable **Backbone.History** properties and methods.
_.extend(Backbone.History.prototype, {
@@ -724,6 +727,7 @@
// Start the hash change handling, returning `true` if the current URL matches
// an existing route, and `false` otherwise.
start : function() {
+ if (historyStarted) throw new Error("Backbone.history has already been started.");
var docMode = document.documentMode;
var oldIE = ($.browser.msie && (!docMode || docMode <= 7));
if (oldIE) {
@@ -734,6 +738,7 @@
} else {
setInterval(this.checkUrl, this.interval);
}
+ historyStarted = true;
return this.loadUrl();
},

0 comments on commit f1e0f6b

Please sign in to comment.