Merge pull request #9 from braddunbar/history

Resolve merge conflicts, add documentation.
This commit is contained in:
Adam Krebs
2014-02-21 11:30:24 -05:00
9 changed files with 55 additions and 21 deletions

2
backbone-min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
// Backbone.js 1.1.1
// Backbone.js 1.1.2
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
@@ -41,7 +41,7 @@
var splice = array.splice;
// Current version of the library. Keep in sync with `package.json`.
Backbone.VERSION = '1.1.1';
Backbone.VERSION = '1.1.2';
// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
// the `$` variable.
@@ -1292,7 +1292,7 @@
return optional ? match : '([^/?]+)';
})
.replace(splatParam, '([^?]*?)');
return new RegExp('^' + route + '(?:\\?(.*))?$');
return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
},
// Given a route, and a URL fragment that it matches, return the array of
@@ -1401,13 +1401,16 @@
// Normalize root to always include a leading and trailing slash.
this.root = ('/' + this.root + '/').replace(rootStripper, '/');
// Proxy an iframe to handle location events on older versions of IE
// Proxy an iframe to handle location events on older versions of IE.
try {
// `documentMode` is defined only in IE>=8.
if ((document.documentMode || 0) < 8) {
// In IE<=7 `createElement` will accept html but throws elsewhere.
var frame = document.createElement(
'<iframe src="javascript:0" style="display:none" tabindex="-1">'
);
var body = document.body;
// Using `appendChild` will throw if the document is not ready.
this.iframe = body.insertBefore(frame, body.firstChild).contentWindow;
if (this._wantsHashChange) this.navigate(fragment);
}
@@ -1465,7 +1468,8 @@
} else if (this._wantsHashChange && this._hasHashChange && !this.iframe) {
removeEventListener('hashchange', this.checkUrl, false);
}
clearInterval(this._checkUrlInterval);
// Some environments will throw when clearing an undefined interval.
if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
History.started = false;
},

View File

@@ -1,6 +1,6 @@
{
"name" : "backbone",
"version" : "1.1.1",
"version" : "1.1.2",
"main" : "backbone.js",
"dependencies" : {
"underscore" : ">=1.5.0"

View File

@@ -1,6 +1,6 @@
{
"name" : "backbone",
"version" : "1.1.1",
"version" : "1.1.2",
"description" : "Give your JS App some Backbone with Models, Views, Collections, and Events.",
"keywords" : ["model", "view", "controller", "router", "server", "client", "browser"],
"repo" : "jashkenas/backbone",

View File

@@ -27,7 +27,7 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<pre><code>Backbone.js <span class="hljs-number">1.1</span><span class="hljs-number">.1</span>
<pre><code>Backbone.js <span class="hljs-number">1.1</span><span class="hljs-number">.2</span>
</code></pre>
</div>
@@ -97,9 +97,8 @@ others that may still expect a global Backbone.</p>
</div>
<div class="content"><div class='highlight'><pre> } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> exports !== <span class="hljs-string">'undefined'</span>) {
<span class="hljs-keyword">var</span> _ = <span class="hljs-built_in">require</span>(<span class="hljs-string">'underscore'</span>), $;
<span class="hljs-keyword">try</span> { $ = <span class="hljs-built_in">require</span>(<span class="hljs-string">'jquery'</span>); } <span class="hljs-keyword">catch</span>(e) {}
factory(root, exports, _, $);</pre></div></div>
<span class="hljs-keyword">var</span> _ = <span class="hljs-built_in">require</span>(<span class="hljs-string">'underscore'</span>);
factory(root, exports, _);</pre></div></div>
</li>
@@ -192,7 +191,7 @@ restored later on, if <code>noConflict</code> is used.</p>
</div>
<div class="content"><div class='highlight'><pre> Backbone.VERSION = <span class="hljs-string">'1.1.1'</span>;</pre></div></div>
<div class="content"><div class='highlight'><pre> Backbone.VERSION = <span class="hljs-string">'1.1.2'</span>;</pre></div></div>
</li>
@@ -3270,7 +3269,7 @@ against the current location hash.</p>
<span class="hljs-keyword">return</span> optional ? match : <span class="hljs-string">'([^/?]+)'</span>;
})
.replace(splatParam, <span class="hljs-string">'([^?]*?)'</span>);
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">'^'</span> + route + <span class="hljs-string">'(?:\\?(.*))?$'</span>);
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">'^'</span> + route + <span class="hljs-string">'(?:\\?([\\s\\S]*))?$'</span>);
},</pre></div></div>
</li>
@@ -3751,7 +3750,7 @@ but possibly useful for unit testing Routers.</p>
<div class="content"><div class='highlight'><pre> stop: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span>
Backbone.$(window).off(<span class="hljs-string">'popstate'</span>, <span class="hljs-keyword">this</span>.checkUrl).off(<span class="hljs-string">'hashchange'</span>, <span class="hljs-keyword">this</span>.checkUrl);
clearInterval(<span class="hljs-keyword">this</span>._checkUrlInterval);
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>._checkUrlInterval) clearInterval(<span class="hljs-keyword">this</span>._checkUrlInterval);
History.started = <span class="hljs-literal">false</span>;
},</pre></div></div>

View File

@@ -285,7 +285,7 @@
<div id="sidebar" class="interface">
<a class="toc_title" href="#">
Backbone.js <span class="version">(1.1.1)</span>
Backbone.js <span class="version">(1.1.2)</span>
</a>
<ul class="toc_section">
<li>&raquo; <a href="http://github.com/jashkenas/backbone">GitHub Repository</a></li>
@@ -559,11 +559,11 @@
<table>
<tr>
<td><a class="punch" href="backbone.js">Development Version (1.1.1)</a></td>
<td><a class="punch" href="backbone.js">Development Version (1.1.2)</a></td>
<td class="text"><i>60kb, Full source, tons of comments</i></td>
</tr>
<tr>
<td><a class="punch" href="backbone-min.js">Production Version (1.1.1)</a></td>
<td><a class="punch" href="backbone-min.js">Production Version (1.1.2)</a></td>
<td class="text" style="line-height: 16px;">
<i>6.5kb, Packed and gzipped</i><br />
<small>(<a href="backbone-min.map">Source Map</a>)</small>
@@ -4031,6 +4031,22 @@ ActiveRecord::Base.include_root_in_json = false
<h2 id="changelog">Change Log</h2>
<b class="header">1.1.2</b> &mdash; <small><i>Feb. 20, 2014</i></small>
&mdash; <a href="https://github.com/jashkenas/backbone/compare/1.1.1...1.1.2">Diff</a>
&mdash; <a href="http://htmlpreview.github.com/?https://raw.github.com/jashkenas/backbone/1.1.2/index.html">Docs</a>
<br />
<ul style="margin-top: 5px;">
<li>
Backbone no longer tries to require jQuery in Node/CommonJS environments,
for better compatibility with folks using Browserify.
If you'd like to have Backbone use jQuery from Node, assign it like so:
<tt>Backbone.$ = require('jquery');</tt>
</li>
<li>
Bugfix for route parameters with newlines in them.
</li>
</ul>
<b class="header">1.1.1</b> &mdash; <small><i>Feb. 13, 2014</i></small> &mdash; <a href="https://github.com/jashkenas/backbone/compare/1.1.0...1.1.1">Diff</a> &mdash; <a href="http://htmlpreview.github.com/?https://raw.github.com/jashkenas/backbone/1.1.1/index.html">Docs</a><br />
<ul style="margin-top: 5px;">
<li>

View File

@@ -19,7 +19,7 @@
"lint": "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
},
"main" : "backbone.js",
"version" : "1.1.1",
"version" : "1.1.2",
"license" : "MIT",
"repository": {
"type": "git",

View File

@@ -788,7 +788,22 @@
}
}
});
var router = new Router;
new Router;
Backbone.history.start({pushState: true});
});
test('newline in route', 1, function() {
location.replace('http://example.com/stuff%0Anonsense?param=foo%0Abar');
Backbone.history.stop();
Backbone.history = _.extend(new Backbone.History, {location: location});
var Router = Backbone.Router.extend({
routes: {
'stuff\nnonsense': function() {
ok(true);
}
}
});
new Router;
Backbone.history.start({pushState: true});
});