Skip to content

Commit

Permalink
version bump to v0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
magalhas committed Nov 6, 2015
1 parent b0531e3 commit 3e04ce3
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 80 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backbone-react-component",
"version": "0.9.0",
"version": "0.10.0",
"description": "Backbone.React.Component is an extendable wrapper for React.Component and brings all the power of Facebook's React to Backbone.js",
"homepage": "https://github.com/magalhas/backbone-react-component",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion dist/backbone-react-component-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 25 additions & 11 deletions dist/backbone-react-component.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Backbone React Component
// ========================
//
// Backbone.React.Component v0.9.0
// Backbone.React.Component v0.10.0
//
// (c) 2014 "Magalhas" José Magalhães <magalhas@gmail.com>
// (c) 2014, 2015 "Magalhas" José Magalhães <magalhas@gmail.com>
// Backbone.React.Component can be freely distributed under the MIT license.
//
//
Expand All @@ -25,18 +25,18 @@
// }
// });
// var model = new Backbone.Model({foo: 'bar'});
// React.render(<MyComponent model={model} />, document.body);
// ReactDOM.render(<MyComponent model={model} />, document.body);

(function (root, factory) {
// Universal module definition
if (typeof define === 'function' && define.amd) {
define(['react', 'backbone', 'underscore'], factory);
define(['react', 'react-dom', 'backbone', 'underscore'], factory);
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = factory(require('react'), require('backbone'), require('underscore'));
module.exports = factory(require('react'), require('react-dom'), require('backbone'), require('underscore'));
} else {
factory(root.React, root.Backbone, root._);
factory(root.React, root.ReactDOM, root.Backbone, root._);
}
}(this, function (React, Backbone, _) {
}(this, function (React, ReactDOM, Backbone, _) {
'use strict';
if (!Backbone.React) {
Backbone.React = {};
Expand Down Expand Up @@ -70,11 +70,11 @@
},
// Sets `this.el` and `this.$el` when the component mounts.
componentDidMount: function () {
this.setElement(React.findDOMNode(this));
this.setElement(ReactDOM.findDOMNode(this));
},
// Sets `this.el` and `this.$el` when the component updates.
componentDidUpdate: function () {
this.setElement(React.findDOMNode(this));
this.setElement(ReactDOM.findDOMNode(this));
},
// When the component gets the initial state, instance a `Wrapper` to take
// care of models and collections binding with `this.state`.
Expand Down Expand Up @@ -134,7 +134,7 @@
if (this.$el) {
els = this.$el.find.apply(this.$el, arguments);
} else {
var el = React.findDOMNode(this);
var el = ReactDOM.findDOMNode(this);
els = el.querySelector.apply(el, arguments);
}

Expand Down Expand Up @@ -283,10 +283,24 @@
}
this.setState.apply(this, arguments);
},
// Get the attributes for the collection or model as array or hash
getAttributes: function (modelOrCollection){
var attrs = [];

// if a collection, get the attributes of each, otherwise return modelOrCollection
if (modelOrCollection instanceof Backbone.Collection) {
for (var i = 0; i < modelOrCollection.models.length; i++) {
attrs.push(modelOrCollection.models[i].attributes);
}
return attrs;
} else {
return modelOrCollection.attributes
}
},
// Sets a model, collection or object into state by delegating to `this.component.setState`.
setState: function (modelOrCollection, key, target, isDeferred) {
var state = {};
var newState = modelOrCollection.toJSON ? modelOrCollection.toJSON() : modelOrCollection;
var newState = this.getAttributes(modelOrCollection);

if (key) {
state[key] = newState;
Expand Down
Loading

0 comments on commit 3e04ce3

Please sign in to comment.