fixing regression committed in r5280. applyDefaults() again allows for an undefined value as the 'from' parameter. thanks tim for report and review. (Closes #1716)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7943 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2008-09-04 02:19:41 +00:00
parent 4783dd5a45
commit 819dc62d09
2 changed files with 11 additions and 2 deletions

View File

@@ -563,7 +563,7 @@ OpenLayers.Util.applyDefaults = function (to, from) {
* properties with the for(property in object) syntax. Explicitly check if * properties with the for(property in object) syntax. Explicitly check if
* the source has its own toString property. * the source has its own toString property.
*/ */
if(!fromIsEvt && from.hasOwnProperty if(!fromIsEvt && from && from.hasOwnProperty
&& from.hasOwnProperty('toString') && !to.hasOwnProperty('toString')) { && from.hasOwnProperty('toString') && !to.hasOwnProperty('toString')) {
to.toString = from.toString; to.toString = from.toString;
} }

View File

@@ -169,7 +169,7 @@
function test_Util_applyDefaults(t) { function test_Util_applyDefaults(t) {
t.plan(11); t.plan(12);
var to = { var to = {
'a': "abra", 'a': "abra",
@@ -204,6 +204,15 @@
var ret = OpenLayers.Util.applyDefaults(to, from); var ret = OpenLayers.Util.applyDefaults(to, from);
t.eq(ret.rand, from.rand, "works with undefined to"); t.eq(ret.rand, from.rand, "works with undefined to");
//regression test for #1716 -- allow undefined from
try {
OpenLayers.Util.applyDefaults({}, undefined);
t.ok(true, "no exception thrown when from is undefined");
} catch(err) {
t.fail("exception thrown when from is undefined:" + err);
}
} }
function test_Util_getParameterString(t) { function test_Util_getParameterString(t) {