Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone.babysitter

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.babysitter - npm Package Compare versions

Comparing version 1.0.0-pre.1 to 1.0.0-pre.2

8

CHANGELOG.md
# Change log
### v1.0.0-pre.2
* Updated Backbone and Underscore version ranges
### v1.0.0-pre.1
* Moved Backbone and Underscore to peerDependencies
### v0.1.11

@@ -4,0 +12,0 @@

93

lib/backbone.babysitter.js

@@ -46,3 +46,3 @@ // Backbone.BabySitter

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

@@ -60,19 +60,4 @@

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();
},

@@ -113,23 +98,4 @@

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();
},

@@ -141,3 +107,3 @@

call: function(method){
this.apply(method, _.tail(arguments));
this.apply(method, _.toArray(arguments).slice(1));
},

@@ -159,2 +125,49 @@

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;
}

@@ -161,0 +174,0 @@ });

@@ -11,3 +11,3 @@ // Backbone.BabySitter

!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,this.add,this)};b.extend(c.prototype,{add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this._updateLength(),this},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.any(this._indexByCustom,function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this),delete this._views[c],this._updateLength(),this},call:function(a){this.apply(a,b.tail(arguments))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){this.length=b.size(this._views)}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="1.0.0-pre.1",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer});
!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,b.bind(this.add,this))};b.extend(c.prototype,{add:function(a,b){return this._add(a,b)._updateLength()},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){return this._remove(a)._updateLength()},call:function(a){this.apply(a,b.toArray(arguments).slice(1))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){return this.length=b.size(this._views),this},_add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this},_remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.some(this._indexByCustom,b.bind(function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this)),delete this._views[c],this}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="1.0.0-pre.1",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer});
//# sourceMappingURL=backbone.babysitter.min.js.map
{
"name": "backbone.babysitter",
"description": "Manage child views in a Backbone.View",
"version": "1.0.0-pre.1",
"version": "1.0.0-pre.2",
"homepage": "https://github.com/marionettejs/backbone.babysitter",

@@ -41,7 +41,7 @@ "main": "lib/backbone.babysitter.js",

"peerDependencies": {
"backbone": ">=0.9.9 <=1.3.2",
"underscore": ">=1.4.0 <=1.8.3"
"backbone": "^1.3.3",
"underscore": "^1.8.3"
},
"devDependencies": {
"backbone": ">=0.9.9 <=1.3.2",
"backbone": ">=1.3.3 <1.4.0",
"grunt": "0.4.4",

@@ -48,0 +48,0 @@ "grunt-cli": "0.1.13",

@@ -11,3 +11,3 @@ describe("childview container", function(){

new Backbone.View()
]
];
container = new Backbone.ChildViewContainer(views);

@@ -89,7 +89,7 @@ });

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";

@@ -106,5 +106,5 @@ view = new Backbone.View({

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

@@ -236,3 +236,3 @@ it("should remove the index by model", function(){

container.each(function(v, k){
container.each(function(v){
views.push(v);

@@ -239,0 +239,0 @@ });

@@ -18,3 +18,3 @@ // BabySitter.ChildViewContainer

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

@@ -32,19 +32,4 @@

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();
},

@@ -85,23 +70,4 @@

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();
},

@@ -113,3 +79,3 @@

call: function(method){
this.apply(method, _.tail(arguments));
this.apply(method, _.toArray(arguments).slice(1));
},

@@ -131,2 +97,49 @@

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;
}

@@ -133,0 +146,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc