From 9e89f4f1733f27897896b0743432cbec47f569e4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 5 Jan 2011 17:24:32 +0000 Subject: [PATCH] Removing the OpenLayers.Util.extend method to the Class.js file to avoid a circular dependency that cannot be resolved with an arbitrary sort order. r=elemoine (closes #2992) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11003 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/BaseTypes/Class.js | 47 +++++++++++++++++++++++++++++ lib/OpenLayers/Util.js | 49 +------------------------------ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Class.js b/lib/OpenLayers/BaseTypes/Class.js index 33395d3820..5effe931b3 100644 --- a/lib/OpenLayers/BaseTypes/Class.js +++ b/lib/OpenLayers/BaseTypes/Class.js @@ -106,3 +106,50 @@ OpenLayers.inherit = function(C, P) { OpenLayers.Util.extend(C.prototype, o); } }; + +/** + * APIFunction: extend + * Copy all properties of a source object to a destination object. Modifies + * 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 + * source - {Object} The object with properties to be set on the destination + * + * Returns: + * {Object} The destination object. + */ +OpenLayers.Util = OpenLayers.Util || {}; +OpenLayers.Util.extend = function(destination, source) { + destination = destination || {}; + if (source) { + for (var property in source) { + var value = source[property]; + if (value !== undefined) { + destination[property] = value; + } + } + + /** + * IE doesn't include the toString property when iterating over an object's + * properties with the for(property in object) syntax. Explicitly check if + * the source has its own toString property. + */ + + /* + * FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative + * prototype object" when calling hawOwnProperty if the source object + * is an instance of window.Event. + */ + + var sourceIsEvt = typeof window.Event == "function" + && source instanceof window.Event; + + if (!sourceIsEvt + && source.hasOwnProperty && source.hasOwnProperty("toString")) { + destination.toString = source.toString; + } + } + return destination; +}; diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index e0edba8a73..1df8630669 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -11,7 +11,7 @@ /** * Namespace: Util */ -OpenLayers.Util = {}; +OpenLayers.Util = OpenLayers.Util || {}; /** * Function: getElement @@ -54,53 +54,6 @@ if(typeof window.$ === "undefined") { window.$ = OpenLayers.Util.getElement; } -/** - * APIFunction: extend - * Copy all properties of a source object to a destination object. Modifies - * 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 - * source - {Object} The object with properties to be set on the destination - * - * Returns: - * {Object} The destination object. - */ -OpenLayers.Util.extend = function(destination, source) { - destination = destination || {}; - if(source) { - for(var property in source) { - var value = source[property]; - if(value !== undefined) { - destination[property] = value; - } - } - - /** - * IE doesn't include the toString property when iterating over an object's - * properties with the for(property in object) syntax. Explicitly check if - * the source has its own toString property. - */ - - /* - * FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative - * prototype object" when calling hawOwnProperty if the source object - * is an instance of window.Event. - */ - - var sourceIsEvt = typeof window.Event == "function" - && source instanceof window.Event; - - if(!sourceIsEvt - && source.hasOwnProperty && source.hasOwnProperty('toString')) { - destination.toString = source.toString; - } - } - return destination; -}; - - /** * Function: removeItem * Remove an object from an array. Iterates through the array