Skip to content

Commit 3e04ce3

Browse files
committed
version bump to v0.10.0
1 parent b0531e3 commit 3e04ce3

10 files changed

+145
-80
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backbone-react-component",
3-
"version": "0.9.0",
3+
"version": "0.10.0",
44
"description": "Backbone.React.Component is an extendable wrapper for React.Component and brings all the power of Facebook's React to Backbone.js",
55
"homepage": "https://github.com/magalhas/backbone-react-component",
66
"authors": [

dist/backbone-react-component-min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/backbone-react-component.js

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Backbone React Component
22
// ========================
33
//
4-
// Backbone.React.Component v0.9.0
4+
// Backbone.React.Component v0.10.0
55
//
6-
// (c) 2014 "Magalhas" José Magalhães <[email protected]>
6+
// (c) 2014, 2015 "Magalhas" José Magalhães <[email protected]>
77
// Backbone.React.Component can be freely distributed under the MIT license.
88
//
99
//
@@ -25,18 +25,18 @@
2525
// }
2626
// });
2727
// var model = new Backbone.Model({foo: 'bar'});
28-
// React.render(<MyComponent model={model} />, document.body);
28+
// ReactDOM.render(<MyComponent model={model} />, document.body);
2929

3030
(function (root, factory) {
3131
// Universal module definition
3232
if (typeof define === 'function' && define.amd) {
33-
define(['react', 'backbone', 'underscore'], factory);
33+
define(['react', 'react-dom', 'backbone', 'underscore'], factory);
3434
} else if (typeof module !== 'undefined' && module.exports) {
35-
module.exports = factory(require('react'), require('backbone'), require('underscore'));
35+
module.exports = factory(require('react'), require('react-dom'), require('backbone'), require('underscore'));
3636
} else {
37-
factory(root.React, root.Backbone, root._);
37+
factory(root.React, root.ReactDOM, root.Backbone, root._);
3838
}
39-
}(this, function (React, Backbone, _) {
39+
}(this, function (React, ReactDOM, Backbone, _) {
4040
'use strict';
4141
if (!Backbone.React) {
4242
Backbone.React = {};
@@ -70,11 +70,11 @@
7070
},
7171
// Sets `this.el` and `this.$el` when the component mounts.
7272
componentDidMount: function () {
73-
this.setElement(React.findDOMNode(this));
73+
this.setElement(ReactDOM.findDOMNode(this));
7474
},
7575
// Sets `this.el` and `this.$el` when the component updates.
7676
componentDidUpdate: function () {
77-
this.setElement(React.findDOMNode(this));
77+
this.setElement(ReactDOM.findDOMNode(this));
7878
},
7979
// When the component gets the initial state, instance a `Wrapper` to take
8080
// care of models and collections binding with `this.state`.
@@ -134,7 +134,7 @@
134134
if (this.$el) {
135135
els = this.$el.find.apply(this.$el, arguments);
136136
} else {
137-
var el = React.findDOMNode(this);
137+
var el = ReactDOM.findDOMNode(this);
138138
els = el.querySelector.apply(el, arguments);
139139
}
140140

@@ -283,10 +283,24 @@
283283
}
284284
this.setState.apply(this, arguments);
285285
},
286+
// Get the attributes for the collection or model as array or hash
287+
getAttributes: function (modelOrCollection){
288+
var attrs = [];
289+
290+
// if a collection, get the attributes of each, otherwise return modelOrCollection
291+
if (modelOrCollection instanceof Backbone.Collection) {
292+
for (var i = 0; i < modelOrCollection.models.length; i++) {
293+
attrs.push(modelOrCollection.models[i].attributes);
294+
}
295+
return attrs;
296+
} else {
297+
return modelOrCollection.attributes
298+
}
299+
},
286300
// Sets a model, collection or object into state by delegating to `this.component.setState`.
287301
setState: function (modelOrCollection, key, target, isDeferred) {
288302
var state = {};
289-
var newState = modelOrCollection.toJSON ? modelOrCollection.toJSON() : modelOrCollection;
303+
var newState = this.getAttributes(modelOrCollection);
290304

291305
if (key) {
292306
state[key] = newState;

0 commit comments

Comments
 (0)