Skip to content

Commit

Permalink
Backbone 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Feb 19, 2019
1 parent c336c8a commit 5de45fc
Show file tree
Hide file tree
Showing 7 changed files with 1,155 additions and 718 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2010-2017 Jeremy Ashkenas, DocumentCloud
Copyright (c) 2010-2019 Jeremy Ashkenas, DocumentCloud

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
2 changes: 1 addition & 1 deletion backbone-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backbone-min.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions backbone.js
@@ -1,6 +1,6 @@
// Backbone.js 1.3.3
// Backbone.js 1.4.0

// (c) 2010-2017 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
Expand Down Expand Up @@ -44,7 +44,7 @@
var slice = Array.prototype.slice;

// Current version of the library. Keep in sync with `package.json`.
Backbone.VERSION = '1.3.3';
Backbone.VERSION = '1.4.0';

// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
// the `$` variable.
Expand Down
1,758 changes: 1,098 additions & 660 deletions docs/backbone.html

Large diffs are not rendered by default.

101 changes: 50 additions & 51 deletions index.html
Expand Up @@ -303,7 +303,7 @@
<div id="sidebar" class="interface">

<a class="toc_title" href="#">
Backbone.js <span class="version">(1.3.3)</span>
Backbone.js <span class="version">(1.4.0)</span>
</a>
<ul class="toc_section">
<li>&raquo; <a href="http://github.com/jashkenas/backbone">GitHub Repository</a></li>
Expand Down Expand Up @@ -593,10 +593,7 @@
<p>
You can report bugs and discuss features on the
<a href="http://github.com/jashkenas/backbone/issues">GitHub issues page</a>,
on Freenode IRC in the <tt>#documentcloud</tt> channel, post questions to the
<a href="https://groups.google.com/forum/#!forum/backbonejs">Google Group</a>,
add pages to the <a href="https://github.com/jashkenas/backbone/wiki">wiki</a>
or send tweets to <a href="http://twitter.com/documentcloud">@documentcloud</a>.
or add pages to the <a href="https://github.com/jashkenas/backbone/wiki">wiki</a>.
</p>

<p>
Expand All @@ -619,17 +616,14 @@ <h2 id="downloads">
<tr>
<td><a class="punch" href="backbone-min.js">Production Version (1.3.3)</a></td>
<td class="text" style="line-height: 16px;">
<i>7.6kb, Packed and gzipped</i><br />
<i>7.9kb, Packed and gzipped</i><br />
<small>(<a href="backbone-min.map">Source Map</a>)</small>
</td>
</tr>
<tr>
<td><a class="punch" href="https://raw.github.com/jashkenas/backbone/master/backbone.js">Edge Version (master)</a></td>
<td>
<i>Unreleased, use at your own risk</i>
<a class="travis-badge" href="https://travis-ci.org/jashkenas/backbone">
<img src="https://travis-ci.org/jashkenas/backbone.png" />
</a>
</td>
</tr>
</table>
Expand All @@ -638,9 +632,7 @@ <h2 id="downloads">
Backbone's only hard dependency is
<a href="http://underscorejs.org/">Underscore.js</a> <small>( >= 1.8.3)</small>.
For RESTful persistence and DOM manipulation with <a href="#View">Backbone.View</a>,
include <b><a href="https://jquery.com/">jQuery</a></b> ( >= 1.11.0), and
<b><a href="https://github.com/douglascrockford/JSON-js">json2.js</a></b> for older
Internet Explorer support.
include <b><a href="https://jquery.com/">jQuery</a></b> ( >= 1.11.0).
<i>(Mimics of the Underscore and jQuery APIs, such as
<a href="https://lodash.com/">Lodash</a> and
<a href="http://zeptojs.com/">Zepto</a>, will
Expand Down Expand Up @@ -1156,14 +1148,15 @@ <h2 id="Model">Backbone.Model</h2>
<p id="Model-preinitialize">
<b class="header">preinitialize</b><code>new Model([attributes], [options])</code>
<br />
For ES2015 classes. If you define a <b>preinitialize</b> method, it will be invoked when
the Model is first created and before any instantiation logic is run for the Model.
For use with models as ES classes. If you define a <b>preinitialize</b>
method, it will be invoked when the Model is first created, before any
instantiation logic is run for the Model.
</p>

<pre>
class Country extends Backbone.Model {
preinitialize(options) {
this.myVar = options.myVar;
preinitialize({countryCode}) {
this.name = COUNTRY_NAMES[countryCode];
}

initialize() { ... }
Expand Down Expand Up @@ -1873,17 +1866,18 @@ <h2 id="Collection">Backbone.Collection</h2>
<p id="Collection-preinitialize">
<b class="header">preinitialize</b><code>new Backbone.Collection([models], [options])</code>
<br />
For ES2015 classes. If you define a <b>preinitialize</b> method, it will be invoked when
the Collection is first created and before any instantiation logic is run for the Collection.
For use with collections as ES classes. If you define a <b>preinitialize</b>
method, it will be invoked when the Collection is first created and before
any instantiation logic is run for the Collection.
</p>

<pre>
class Library extends Backbone.Collection {
preinitialize() {
this.on("add", function() {
console.log("Add model event got fired!");
};
}
preinitialize() {
this.on("add", function() {
console.log("Add model event got fired!");
};
}
}
</pre>

Expand Down Expand Up @@ -2562,23 +2556,24 @@ <h2 id="Router">Backbone.Router</h2>
<p id="Router-preinitialize">
<b class="header">preinitialize</b><code>new Backbone.Router([options])</code>
<br />
For ES2015 classes. If you define a <b>preinitialize</b> method, it will be invoked when
the Router is first created and before any instantiation logic is run for the Router.
For use with routers as ES classes. If you define a <b>preinitialize</b>
method, it will be invoked when the Router is first created and before
any instantiation logic is run for the Router.
</p>

<pre>
class Router extends Backbone.Router {
preinitialize() {
// Override execute method
this.execute = function(callback, args, name) {
if (!loggedIn) {
goToLogin();
return false;
}
args.push(parseQueryString(args.pop()));
if (callback) callback.apply(this, args);
preinitialize() {
// Override execute method
this.execute = function(callback, args, name) {
if (!loggedIn) {
goToLogin();
return false;
}
args.push(parseQueryString(args.pop()));
if (callback) callback.apply(this, args);
}
}
}
</pre>

Expand Down Expand Up @@ -2909,19 +2904,22 @@ <h2 id="View">Backbone.View</h2>
<p id="View-preinitialize">
<b class="header">preinitialize</b><code>new View([options])</code>
<br />
For ES2015 classes. If you define a <b>preinitialize</b> method, it will be invoked when
the View is first created and before any instantiation logic is run for the View.
For use with views as ES classes. If you define a <b>preinitialize</b>
method, it will be invoked when the view is first created, before any
instantiation logic is run.
</p>

<pre>
class Document extends Backbone.View {
preinitialize(options) {
this.myVar = options.myVar;
}
preinitialize({autoRender}) {
this.autoRender = autoRender;
}

initialize() {
initialize() {
if (this.autoRender) {
this.listenTo(this.model, "change", this.render);
}
}
}
</pre>

Expand Down Expand Up @@ -3589,9 +3587,9 @@ <h2 id="faq">F.A.Q.</h2>
<h2 id="examples">Examples</h2>

<p>
The list of examples that follows, while long, is not exhaustive. If you've
worked on an app that uses Backbone, please add it to the
<a href="https://github.com/jashkenas/backbone/wiki/Projects-and-Companies-using-Backbone">wiki page of Backbone apps</a>.
The list of examples that follows, while long, is not exhaustive — nor in
any way current. If you've worked on an app that uses Backbone, please
add it to the <a href="https://github.com/jashkenas/backbone/wiki/Projects-and-Companies-using-Backbone">wiki page of Backbone apps</a>.
</p>

<p id="examples-todos">
Expand Down Expand Up @@ -4444,29 +4442,30 @@ <h2 id="examples-tzigla">Tzigla</h2>

<h2 id="changelog">Change Log</h2>

<b class="header">1.4.0</b> &mdash; <small><i>Apr. 8, 2017</i></small>
<b class="header">1.4.0</b> &mdash; <small><i>Feb. 19, 2019</i></small>
&mdash; <a href="https://github.com/jashkenas/backbone/compare/1.3.3...1.4.0">Diff</a>
&mdash; <a href="https://cdn.rawgit.com/jashkenas/backbone/1.4.0/index.html">Docs</a>
<br />
<ul style="margin-top: 5px;">
<li>
Added support for setting instance properties before the constructor in <tt>ES2015 classes</tt> with a <tt>preinitialize</tt> method.
Collections now support the <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols">Javascript Iterator Protocol!</a>
</li>
<li>
Collections now support the [Javascript Iterator Protocol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols)
<tt>listenTo</tt> uses the listened object's public <tt>on</tt> method.
This helps maintain interoperability between Backbone and other event
libraries (including Node.js).
</li>
<li>
`#listenTo` uses the listened object's public `#on` method. This keeps interop between Backbone and other event libraries (including Node.js).
Added support for setting instance properties before the constructor in
<tt>ES2015 classes</tt> with a <tt>preinitialize</tt> method.
</li>
<li>
<tt>Collection.get</tt> now checks if obj is a <tt>Model</tt> to allow retrieving models with an `attributes` key.
<tt>Collection.get</tt> now checks if obj is a <tt>Model</tt> to allow
retrieving models with an `attributes` key.
</li>
<li>
Fixed several issues with Router's URL hashing and parsing.
</li>
<li>
We are no longer testing for <= IE8, with the goal of eventually refactoring some of the older hacks out.
</li>
</ul>

<b class="header">1.3.3</b> &mdash; <small><i>Apr. 5, 2016</i></small>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -33,7 +33,7 @@
"lint": "eslint backbone.js test/*.js"
},
"main": "backbone.js",
"version": "1.3.3",
"version": "1.4.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down

0 comments on commit 5de45fc

Please sign in to comment.