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

can-list

Package Overview
Dependencies
Maintainers
9
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-list - npm Package Compare versions

Comparing version 4.0.0-pre.5 to 4.0.0-pre.6

54

can-list_test.js

@@ -540,4 +540,4 @@ var List = require('can-list');

var PATCHES = [
[ { deleteCount: 2, index: 0 } ],
[ { index: 0, insert: ["A", "B"], deleteCount: 0 } ]
[ { deleteCount: 2, index: 0, type: "splice" } ],
[ { index: 0, insert: ["A", "B"], deleteCount: 0, type: "splice" } ]
];

@@ -559,1 +559,51 @@

});
QUnit.test("can.onInstancePatches basics", function(){
var People = List.extend({});
var calls = [];
function handler(obj, patches) {
calls.push([obj, patches]);
}
People[canSymbol.for("can.onInstancePatches")](handler);
var list = new People([1,2]);
list.push(3);
list.attr("count", 8);
People[canSymbol.for("can.offInstancePatches")](handler);
list.push(4);
list.attr("count", 7);
QUnit.deepEqual(calls,[
[list, [{type: "splice", index: 2, deleteCount: 0, insert: [3]} ] ],
[list, [{type: "set", key: "count", value: 8} ] ]
]);
});
QUnit.test("can.onInstanceBoundChange basics", function(){
var People = List.extend({});
var calls = [];
function handler(obj, patches) {
calls.push([obj, patches]);
}
People[canSymbol.for("can.onInstanceBoundChange")](handler);
var people = new People([]);
var bindHandler = function(){};
canReflect.onKeyValue(people,"length", bindHandler);
canReflect.offKeyValue(people,"length", bindHandler);
People[canSymbol.for("can.offInstanceBoundChange")](handler);
canReflect.onKeyValue(people,"length", bindHandler);
canReflect.offKeyValue(people,"length", bindHandler);
QUnit.deepEqual(calls,[
[people, true ],
[people, false ]
]);
});

23

can-list.js

@@ -73,17 +73,22 @@ /* jshint -W079 */

_triggerChange: function (attr, how, newVal, oldVal) {
Map.prototype._triggerChange.apply(this, arguments);
// `batchTrigger` direct add and remove events...
var index = +attr;
var index = +attr, patches;
// Make sure this is not nested and not an expando
if (!~(""+attr).indexOf('.') && !isNaN(index)) {
if(bubble.isBubbling(this, "change")) {
canEvent.dispatch.call(this, {
type: "change",
target: this
}, [attr, how, newVal, oldVal]);
}
if (how === 'add') {
canEvent.dispatch.call(this, how, [newVal, index]);
patches = [{insert: newVal, index: index, deleteCount: 0, type: "splice"}];
canEvent.dispatch.call(this, {type: how, patches: patches}, [newVal, index]);
canEvent.dispatch.call(this, 'length', [this.length]);
canEvent.dispatch.call(this, 'can.onPatches', [[{insert: newVal, index: index, deleteCount: 0}]]);
canEvent.dispatch.call(this, 'can.onPatches', [patches]);
} else if (how === 'remove') {
canEvent.dispatch.call(this, how, [oldVal, index]);
patches = [{index: index, deleteCount: oldVal.length, type: "splice"}];
canEvent.dispatch.call(this, {type: how, patches: patches}, [oldVal, index]);
canEvent.dispatch.call(this, 'length', [this.length]);
canEvent.dispatch.call(this, 'can.onPatches', [[{index: index, deleteCount: oldVal.length}]]);
canEvent.dispatch.call(this, 'can.onPatches', [patches]);
} else {

@@ -93,2 +98,4 @@ canEvent.dispatch.call(this, how, [newVal, index]);

} else {
Map.prototype._triggerChange.apply(this, arguments);
}

@@ -95,0 +102,0 @@

{
"name": "can-list",
"version": "4.0.0-pre.5",
"version": "4.0.0-pre.6",
"description": "Observable lists",

@@ -50,3 +50,3 @@ "homepage": "http://canjs.com",

"can-queues": "<2.0.0",
"can-map": "^4.0.0-pre.0"
"can-map": "^4.0.0-pre.5"
},

@@ -53,0 +53,0 @@ "devDependencies": {

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