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

@@ -38,7 +38,8 @@ if ($ == null) {
/**
* APIFunction: extend
* Copy all properties of a source object to a destination object. Modifies
* the passed in destination object.
* the passed in destination object. Any properties on the source object
* that are set to undefined will not be (re)set on the destination object.
*
* Parameters:
* destination - {Object} The object that will be modified
@@ -50,7 +51,10 @@ if ($ == null) {
OpenLayers.Util.extend = function(destination, source) {
if(destination && source) {
for(var property in source) {
destination[property] = source[property];
value = source[property];
if(value !== undefined) {
destination[property] = value;
}
}
/**
* IE doesn't include the toString property when iterating over an object's