Skip to content

Commit

Permalink
Merge pull request #83 from marionettejs/major
Browse files Browse the repository at this point in the history
Bump and build v1.0.0
  • Loading branch information
paulfalgout authored Jan 11, 2022
2 parents d60503b + 5d5a705 commit ea83796
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 102 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change log

### v1.0.0

* Updated Backbone and Underscore version ranges again

### v1.0.0-pre.2

* Updated Backbone and Underscore version ranges

### v1.0.0-pre.1

* Moved Backbone and Underscore to peerDependencies

### v0.1.12

* Bump version range of backbone support.
Expand Down
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backbone.babysitter",
"version": "0.1.12",
"version": "1.0.0",
"homepage": "https://github.com/marionettejs/backbone.babysitter",
"authors": [
"Derick Bailey <[email protected]>"
Expand All @@ -17,8 +17,8 @@
"browser"
],
"dependencies": {
"backbone": ">=0.9.9 <1.4",
"underscore": ">=1.4.0 <=1.8.3"
"backbone": ">=1.3.3",
"underscore": ">=1.8.3"
},
"license": "MIT",
"ignore": [
Expand Down
99 changes: 56 additions & 43 deletions lib/backbone.babysitter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Backbone.BabySitter
// -------------------
// v0.1.11
// v1.0.0
//
// Copyright (c)2016 Derick Bailey, Muted Solutions, LLC.
// Copyright (c)2019 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
//
// http://github.com/marionettejs/backbone.babysitter
Expand Down Expand Up @@ -43,7 +43,7 @@
this._indexByCustom = {};
this._updateLength();

_.each(views, this.add, this);
_.each(views, _.bind(this.add, this));
};

// Container Methods
Expand All @@ -56,23 +56,8 @@
// cid (and model itself). Optionally specify
// a custom key to store an retrieve the view.
add: function(view, customIndex){
var viewCid = view.cid;

// store the view
this._views[viewCid] = view;

// index it by model
if (view.model){
this._indexByModel[view.model.cid] = viewCid;
}

// index by custom
if (customIndex){
this._indexByCustom[customIndex] = viewCid;
}

this._updateLength();
return this;
return this._add(view, customIndex)
._updateLength();
},

// Find a view by the model that was attached to
Expand Down Expand Up @@ -108,34 +93,15 @@

// Remove a view
remove: function(view){
var viewCid = view.cid;

// delete model index
if (view.model){
delete this._indexByModel[view.model.cid];
}

// delete custom index
_.any(this._indexByCustom, function(cid, key) {
if (cid === viewCid) {
delete this._indexByCustom[key];
return true;
}
}, this);

// remove the view from the container
delete this._views[viewCid];

// update the length
this._updateLength();
return this;
return this._remove(view)
._updateLength();
},

// Call a method on every view in the container,
// passing parameters to the call method one at a
// time, like `function.call`.
call: function(method){
this.apply(method, _.tail(arguments));
this.apply(method, _.toArray(arguments).slice(1));
},

// Apply a method on every view in the container,
Expand All @@ -152,6 +118,53 @@
// Update the `.length` attribute on this container
_updateLength: function(){
this.length = _.size(this._views);

return this;
},
// To be used when avoiding call _updateLength
// When you are done adding all your new views
// call _updateLength
_add: function(view, customIndex){
var viewCid = view.cid;

// store the view
this._views[viewCid] = view;

// index it by model
if (view.model){
this._indexByModel[view.model.cid] = viewCid;
}

// index by custom
if (customIndex){
this._indexByCustom[customIndex] = viewCid;
}

return this;
},
// To be used when avoiding call _updateLength
// When you are done adding all your new views
// call _updateLength
_remove: function (view){
var viewCid = view.cid;

// delete model index
if (view.model){
delete this._indexByModel[view.model.cid];
}

// delete custom index
_.some(this._indexByCustom, _.bind(function(cid, key) {
if (cid === viewCid) {
delete this._indexByCustom[key];
return true;
}
}, this));

// remove the view from the container
delete this._views[viewCid];

return this;
}
});

Expand All @@ -178,7 +191,7 @@
})(Backbone, _);


Backbone.ChildViewContainer.VERSION = '0.1.11';
Backbone.ChildViewContainer.VERSION = '1.0.0';

Backbone.ChildViewContainer.noConflict = function () {
Backbone.ChildViewContainer = previousChildViewContainer;
Expand Down
1 change: 0 additions & 1 deletion lib/backbone.babysitter.map

This file was deleted.

6 changes: 3 additions & 3 deletions lib/backbone.babysitter.min.js

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

2 changes: 1 addition & 1 deletion lib/backbone.babysitter.min.js.map

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

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "backbone.babysitter",
"description": "Manage child views in a Backbone.View",
"version": "0.1.12",
"version": "1.0.0",
"homepage": "https://github.com/marionettejs/backbone.babysitter",
"main": "lib/backbone.babysitter.js",
"keywords": [
Expand Down Expand Up @@ -37,11 +37,12 @@
"url": "https://github.com/marionettejs/backbone.babysitter.git"
},
"github": "https://github.com/marionettejs/backbone.babysitter",
"dependencies": {
"backbone": ">=0.9.9 <=1.3.x",
"underscore": ">=1.4.0 <=1.8.3"
"peerDependencies": {
"backbone": "^1.3.3",
"underscore": "^1.8.3"
},
"devDependencies": {
"backbone": ">=1.3.3",
"grunt": "0.4.4",
"grunt-cli": "0.1.13",
"grunt-contrib-concat": "0.1.2",
Expand All @@ -51,6 +52,7 @@
"grunt-contrib-uglify": "1.0.1",
"grunt-contrib-watch": "0.2.0",
"grunt-preprocess": "4.0.0",
"grunt-template": "0.2.3"
"grunt-template": "0.2.3",
"underscore": ">=1.4.0 <=1.9.1"
}
}
12 changes: 6 additions & 6 deletions spec/javascripts/childviewContainer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("childview container", function(){
new Backbone.View(),
new Backbone.View(),
new Backbone.View()
]
];
container = new Backbone.ChildViewContainer(views);
});

Expand Down Expand Up @@ -85,11 +85,11 @@ describe("childview container", function(){
});

describe("when removing a view", function(){
var container, view, model, col, cust;
var container, view, model, cust;

beforeEach(function(){
model = new Backbone.Model();
cust = "custome indexer";
cust = "custom indexer";

view = new Backbone.View({
model: model
Expand All @@ -101,9 +101,9 @@ describe("childview container", function(){
container.remove(view);
});

it("should update the size of the chidren", function(){
it("should update the size of the children", function(){
expect(container.length).toBe(0);
})
});

it("should remove the index by model", function(){
var v = container.findByModel(model);
Expand Down Expand Up @@ -230,7 +230,7 @@ describe("childview container", function(){
container = new Backbone.ChildViewContainer();
container.add(view);

container.each(function(v, k){
container.each(function(v){
views.push(v);
});
});
Expand Down
Loading

0 comments on commit ea83796

Please sign in to comment.