Create applyDefaults() function that works similarly to extend(), but without replacing existing keys.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@111 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -604,3 +604,20 @@ OpenLayers.getParameterString = function(params) {
|
||||
OpenLayers.Util.getImagesLocation = function () {
|
||||
return "img/";
|
||||
};
|
||||
|
||||
/** Takes a hash and copies any keys that don't exist from
|
||||
* another hash, by analogy with Object.extend() from
|
||||
* Prototype.js.
|
||||
*
|
||||
* @param {Object} to
|
||||
* @param {Object} from
|
||||
* @return {Object}
|
||||
*/
|
||||
OpenLayers.Util.applyDefaults = function (to, from) {
|
||||
for (var key in from) {
|
||||
if (to[key] == null) {
|
||||
to[key] = from[key];
|
||||
}
|
||||
}
|
||||
return to;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user