can-reflect
Advanced tools
Comparing version 1.1.0-pre.2 to 1.1.0-pre.3
{ | ||
"name": "can-reflect", | ||
"version": "1.1.0-pre.2", | ||
"version": "1.1.0-pre.3", | ||
"description": "reflection on unknown data types", | ||
@@ -5,0 +5,0 @@ "homepage": "http://canjs.com", |
@@ -401,2 +401,7 @@ var QUnit = require('steal-qunit'); | ||
QUnit.test("can assign undefined values", function(){ | ||
var obj = shapeReflections.assignMap({}, {foo: undefined}); | ||
QUnit.ok(obj.hasOwnProperty("foo"), "has an undefined foo"); | ||
}); | ||
/*QUnit.module('can-reflect: shape reflections: proto chain'); | ||
@@ -403,0 +408,0 @@ |
@@ -497,5 +497,6 @@ var canSymbol = require("can-symbol"); | ||
// read each key and set it on target | ||
var targetKeyMap = makeMap(this.getOwnEnumerableKeys(target)); | ||
this.eachKey(source,function(value, key){ | ||
var curVal = getSetReflections.getKeyValue(target, key); | ||
if(curVal !== value) { | ||
// if the target doesn't have this key or the keys are not the same | ||
if(!targetKeyMap[target] || getSetReflections.getKeyValue(target, key) !== value) { | ||
getSetReflections.setKeyValue(target, key, value); | ||
@@ -522,15 +523,20 @@ } | ||
var targetKeyMap = makeMap(this.getOwnEnumerableKeys(target)); | ||
this.eachKey(source, function(newVal, key){ | ||
if(!targetKeyMap[key]) { | ||
// set no matter what | ||
getSetReflections.setKeyValue(target, key, newVal); | ||
} else { | ||
var curVal = getSetReflections.getKeyValue(target, key); | ||
var curVal = getSetReflections.getKeyValue(target, key); | ||
// if either was primitive, no recursive update possible | ||
if(newVal === curVal) { | ||
// do nothing | ||
} else if(typeReflections.isPrimitive(curVal) || typeReflections.isPrimitive(newVal)) { | ||
getSetReflections.setKeyValue(target, key, newVal); | ||
} else{ | ||
this.assignDeep(curVal, newVal); | ||
// if either was primitive, no recursive update possible | ||
if(newVal === curVal) { | ||
// do nothing | ||
} else if(typeReflections.isPrimitive(curVal) || typeReflections.isPrimitive(newVal)) { | ||
getSetReflections.setKeyValue(target, key, newVal); | ||
} else{ | ||
this.assignDeep(curVal, newVal); | ||
} | ||
} | ||
}, this); | ||
@@ -629,5 +635,3 @@ return target; | ||
updateDeep.call(target, source); | ||
} | ||
if( typeReflections.isMoreListLikeThanMapLike(source) ) { | ||
} else if( typeReflections.isMoreListLikeThanMapLike(source) ) { | ||
// list-like | ||
@@ -649,2 +653,3 @@ this.updateDeepList(target, source); | ||
}, this); | ||
return target; | ||
} | ||
@@ -651,0 +656,0 @@ }; |
97941
2507