extend now only sets defined properties on the destination - if your source has a property set to undefined, the destination property will not be set (closes #1160).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@5281 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-11-26 23:45:43 +00:00
parent d7905ec735
commit 12c7cb07b2
2 changed files with 12 additions and 5 deletions

View File

@@ -591,7 +591,7 @@
}
function tests_Util_extend(t) {
t.plan(5);
t.plan(6);
var source = {
num: Math.random(),
@@ -603,9 +603,10 @@
},
toString: function() {
return "source";
}
},
nada: undefined
};
var destination = OpenLayers.Util.extend({}, source);
var destination = OpenLayers.Util.extend({nada: "untouched"}, source);
t.eq(destination.num, source.num,
"extend properly sets primitive property on destination");
t.eq(destination.obj, source.obj,
@@ -614,6 +615,8 @@
"extend properly sets function property on destination");
t.eq(destination.toString(), "source",
"extend properly sets custom toString method");
t.eq(destination.nada, "untouched",
"undefined source properties don't clobber existing properties");
t.eq(window.property, undefined, "Property variable not clobbered.");
}