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

can-map

Package Overview
Dependencies
Maintainers
10
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-map - npm Package Compare versions

Comparing version 3.4.2 to 3.5.0

dist/amd/bubble.js

43

can-map_test.js

@@ -458,1 +458,44 @@ /* jshint asi:true */

});
QUnit.test(".attr(props) should overwrite if _legacyAttrBehavior is true (#112)", function(){
Map.prototype._legacyAttrBehavior = true;
var myMap1Instance = new Map({prop1: new Map()});
var changes = 0;
myMap1Instance.on("prop1", function() {
changes++;
});
var map2 = new Map({prop1: "xyz"});
myMap1Instance.attr({
"prop1": map2
});
delete Map.prototype._legacyAttrBehavior;
QUnit.equal(changes,1, "caused a change event");
QUnit.equal(myMap1Instance.attr("prop1"), map2, "overwrite with maps");
});
QUnit.test(".attr() leaves typed instances alone if _legacyAttrBehavior is true (#111)", function(){
Map.prototype._legacyAttrBehavior = true;
function MyClass(value){
this.value = value;
}
MyClass.prototype.log = function(){
return this.value;
};
var myMap = new Map({
myClass: new MyClass(5)
});
QUnit.equal( myMap.attr().myClass, myMap.attr("myClass") )
delete Map.prototype._legacyAttrBehavior;
});

60

can-map.js

@@ -470,3 +470,8 @@ /* jshint -W079 */

_getAttrs: function(){
return canReflect.unwrap(this, CIDMap);
if(this._legacyAttrBehavior) {
return mapHelpers.serialize(this, 'attr', {});
} else {
return canReflect.unwrap(this, CIDMap);
}
},

@@ -479,2 +484,5 @@ // ### _setAttrs

_setAttrs: function (props, remove) {
if(this._legacyAttrBehavior) {
return this.__setAttrs(props, remove);
}
if(remove === true) {

@@ -487,3 +495,53 @@ this[canSymbol.for("can.updateDeep")](props);

},
__setAttrs: function (props, remove) {
props = assign({}, props);
var prop,
self = this,
newVal;
// Batch all of the change events until we are done.
canBatch.start();
// Merge current properties with the new ones.
this._each(function (curVal, prop) {
// You can not have a _cid property; abort.
if (prop === "_cid") {
return;
}
newVal = props[prop];
// If we are merging, remove the property if it has no value.
if (newVal === undefined) {
if (remove) {
self.removeAttr(prop);
}
return;
}
// Run converter if there is one. Remove in 3.0.
if (self.__convert) {
newVal = self.__convert( prop, newVal );
}
if ( types.isMapLike(curVal) && mapHelpers.canMakeObserve(newVal) ) {
curVal.attr(newVal, remove);
// Otherwise just set.
} else if (curVal !== newVal) {
self.__set(prop, self.__type(newVal, prop), curVal);
}
delete props[prop];
});
// Add remaining props.
for (prop in props) {
// Ignore _cid.
if (prop !== "_cid") {
newVal = props[prop];
this._set(prop, newVal, true);
}
}
canBatch.stop();
return this;
},
serialize: function () {

@@ -490,0 +548,0 @@ return canReflect.serialize(this, CIDMap);

9

map-helpers.js

@@ -10,2 +10,3 @@ // # can/map/map_hepers

var canReflect = require('can-reflect');
var canSymbol = require("can-symbol");
// ## POJOs to Map instance helpers

@@ -83,3 +84,3 @@

// `where` - the target Object or Array that becomes the serialized result.
/*serialize: (function(){
serialize: (function(){

@@ -135,3 +136,3 @@ // A temporary mapping of map cids to the serialized result.

};
})(),*/
})(),

@@ -141,3 +142,3 @@ // ## getValue

// returns the value of `val`.
/*getValue: function(map, name, val, how){
getValue: function(map, name, val, how){
if(how === "attr") {

@@ -151,3 +152,3 @@ how = canSymbol.for("can.getValue");

}
},*/
},

@@ -154,0 +155,0 @@ // ## define

{
"name": "can-map",
"version": "3.4.2",
"version": "3.5.0",
"description": "Observable Objects",

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

"version": "git commit -am \"Update dist for release\" && git checkout -b release && git add -f dist/",
"postversion": "git push --tags && git checkout master && git branch -D release && git push",
"postversion": "git push --tags && git checkout v3-legacy && git branch -D release && git push",
"testee": "testee test/test.html --browsers firefox",

@@ -17,0 +17,0 @@ "test": "npm run detect-cycle && npm run jshint && npm run testee",

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