Make OpenLayers.Util.applyDefaults() return the modified object. To be consistent with OpenLayers.Util.Extend() and be able to use anonymous object as the 'to' object. Thanks fredj for the patch and tests. Thanks euzuro and crschmidt for the reviews. (closes #992)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5162 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -503,6 +503,7 @@ OpenLayers.Util.applyDefaults = function (to, from) {
|
|||||||
to[key] = from[key];
|
to[key] = from[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return to;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
|
|
||||||
function test_06_Util_applyDefaults(t) {
|
function test_06_Util_applyDefaults(t) {
|
||||||
|
|
||||||
t.plan(4);
|
t.plan(8);
|
||||||
|
|
||||||
var to = {
|
var to = {
|
||||||
'a': "abra",
|
'a': "abra",
|
||||||
@@ -161,6 +161,12 @@
|
|||||||
t.eq( to["a"], "abra", "key present in to but not from maintained");
|
t.eq( to["a"], "abra", "key present in to but not from maintained");
|
||||||
t.eq( to["b"], "blorg", "key present in to and from, maintained in to");
|
t.eq( to["b"], "blorg", "key present in to and from, maintained in to");
|
||||||
t.eq( to["c"], "press", "key present in from and not to successfully copied to to");
|
t.eq( to["c"], "press", "key present in from and not to successfully copied to to");
|
||||||
|
|
||||||
|
var ret = OpenLayers.Util.applyDefaults({'a': "abra",'b': "blorg"}, from);
|
||||||
|
t.ok( ret instanceof Object, " applyDefaults returns an object");
|
||||||
|
t.eq( ret["a"], "abra", "key present in ret but not from maintained");
|
||||||
|
t.eq( ret["b"], "blorg", "key present in ret and from, maintained in ret");
|
||||||
|
t.eq( ret["c"], "press", "key present in from and not ret successfully copied to ret");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_07_Util_getParameterString(t) {
|
function test_07_Util_getParameterString(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user