Skip to content

Commit

Permalink
Merge 0e968b5 into 49831e5
Browse files Browse the repository at this point in the history
  • Loading branch information
dhritzkiv committed May 20, 2016
2 parents 49831e5 + 0e968b5 commit b6541c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions ampersand-state.js
Expand Up @@ -14,7 +14,6 @@ var isFunction = require('lodash/isFunction');
var _isEqual = require('lodash/isEqual'); // to avoid shadowing
var has = require('lodash/has');
var result = require('lodash/result');
var bind = require('lodash/bind'); // because phantomjs doesn't have Function#bind
var union = require('lodash/union');
var Events = require('ampersand-events');
var KeyTree = require('key-tree-store');
Expand Down Expand Up @@ -103,12 +102,13 @@ assign(Base.prototype, Events, {
serialize: function (options) {
var attrOpts = assign({props: true}, options);
var res = this.getAttributes(attrOpts, true);
forOwn(this._children, bind(function (value, key) {
res[key] = this[key].serialize();
}, this));
forOwn(this._collections, bind(function (value, key) {
res[key] = this[key].serialize();
}, this));

var setFromSerializedValue = function (value, key) {
res[key] = this[key].serialize();
}.bind(this);

forOwn(this._children, setFromSerializedValue);
forOwn(this._collections, setFromSerializedValue);
return res;
},

Expand Down Expand Up @@ -382,13 +382,13 @@ assign(Base.prototype, Events, {
// Determine which comparison algorithm to use for comparing a property
_getCompareForType: function (type) {
var dataType = this._dataTypes[type];
if (dataType && dataType.compare) return bind(dataType.compare, this);
if (dataType && dataType.compare) return dataType.compare.bind(this);
return _isEqual; // if no compare function is defined, use _.isEqual
},

_getOnChangeForType : function(type){
var dataType = this._dataTypes[type];
if (dataType && dataType.onChange) return bind(dataType.onChange, this);
if (dataType && dataType.onChange) return dataType.onChange.bind(this);
return noop;
},

Expand Down Expand Up @@ -506,13 +506,13 @@ assign(Base.prototype, Events, {
// adding a name to the change string.
_getCachedEventBubblingHandler: function (propertyName) {
if (!this._eventBubblingHandlerCache[propertyName]) {
this._eventBubblingHandlerCache[propertyName] = bind(function (name, model, newValue) {
this._eventBubblingHandlerCache[propertyName] = function (name, model, newValue) {
if (changeRE.test(name)) {
this.trigger('change:' + propertyName + '.' + name.split(':')[1], model, newValue);
} else if (name === 'change') {
this.trigger('change', this);
}
}, this);
}.bind(this);
}
return this._eventBubblingHandlerCache[propertyName];
},
Expand Down
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -19,18 +19,18 @@
"ampersand-version": "^1.0.0",
"array-next": "~0.0.1",
"key-tree-store": "^1.3.0",
"lodash": "^4.11.1"
"lodash": "^4.12.0"
},
"devDependencies": {
"ampersand-collection": "^1.3.2",
"ampersand-registry": "0.x.x",
"coveralls": "^2.11.4",
"istanbul": "^0.4.0",
"jshint": "^2.5.3",
"phantomjs": "^2.1.7",
"coveralls": "^2.11.9",
"istanbul": "^0.4.3",
"jshint": "^2.9.2",
"phantomjs-prebuilt": "^2.1.7",
"precommit-hook": "^3.0.0",
"tape": "^4.0.3",
"zuul": "^3.9.0"
"tape": "^4.5.1",
"zuul": "^3.10.1"
},
"homepage": "https://github.com/ampersandjs/ampersand-state",
"keywords": [
Expand Down

0 comments on commit b6541c7

Please sign in to comment.