Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename _boundDataObjects -> _boundDataObjectsByCid and be a hash

  • Loading branch information...
commit d336c097d733b16d537bed63c9a886e10050519b 1 parent 2e0065e
Ryan Eastridge authored
Showing with 6 additions and 6 deletions.
  1. +4 −4 src/data-object.js
  2. +1 −1  src/event.js
  3. +1 −1  src/thorax.js
View
8 src/data-object.js
@@ -55,12 +55,12 @@ function dataObject(type, spec) {
_.extend(Thorax.View.prototype, {
bindDataObject: function(dataObject, options) {
var type = getDataObjectType(dataObject);
- if (this._boundDataObjects.indexOf(dataObject) !== -1) {
+ if (this._boundDataObjectsByCid[dataObject.cid]) {
return false;
}
// Collections do not have a cid attribute by default
ensureDataObjectCid(type, dataObject);
- this._boundDataObjects.push(dataObject);
+ this._boundDataObjectsByCid[dataObject.cid] = dataObject;
var options = this._modifyDataObjectOptions(dataObject, _.extend({}, inheritVars[type].defaultOptions, options));
this._objectOptionsByCid[dataObject.cid] = options;
@@ -78,10 +78,10 @@ _.extend(Thorax.View.prototype, {
},
unbindDataObject: function (dataObject) {
- if (this._boundDataObjects.indexOf(dataObject) === -1) {
+ if (!this._boundDataObjectsByCid[dataObject.cid]) {
return false;
}
- this._boundDataObjects = _.without(this._boundDataObjects, dataObject);
+ delete this._boundDataObjectsByCid[dataObject.cid];
dataObject.trigger('freeze');
this.stopListening(dataObject);
delete this._objectOptionsByCid[dataObject.cid];
View
2  src/event.js
@@ -46,7 +46,7 @@ _.extend(Thorax.View, {
_.extend(Thorax.View.prototype, {
freeze: function(options) {
- _.each(this._boundDataObjects, this.unbindDataObject, this);
+ _.each(this._boundDataObjectsByCid, this.unbindDataObject, this);
options = _.defaults(options || {}, {
dom: true,
children: true
View
2  src/thorax.js
@@ -46,7 +46,7 @@ Thorax.View = Backbone.View.extend({
var self = this;
this._objectOptionsByCid = {};
- this._boundDataObjects = [];
+ this._boundDataObjectsByCid = {};
// Setup object event tracking
_.each(inheritVars, function(obj) {
Please sign in to comment.
Something went wrong with that request. Please try again.