diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 0eb4de6c69..8daaaea6f4 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -56,12 +56,24 @@ OpenLayers.Util.extend = function(destination, source) { 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. */ - if(source.hasOwnProperty && source.hasOwnProperty('toString')) { + + /* + * 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; } } @@ -510,9 +522,18 @@ OpenLayers.Util.upperCaseObject = function (object) { * in place and returned by this function. */ OpenLayers.Util.applyDefaults = function (to, from) { + + /* + * 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 fromIsEvt = typeof window.Event == "function" + && from instanceof window.Event; + for (var key in from) { if (to[key] === undefined || - (from.hasOwnProperty + (!fromIsEvt && from.hasOwnProperty && from.hasOwnProperty(key) && !to.hasOwnProperty(key))) { to[key] = from[key]; } @@ -522,7 +543,7 @@ OpenLayers.Util.applyDefaults = function (to, from) { * properties with the for(property in object) syntax. Explicitly check if * the source has its own toString property. */ - if(from.hasOwnProperty + if(!fromIsEvt && from.hasOwnProperty && from.hasOwnProperty('toString') && !to.hasOwnProperty('toString')) { to.toString = from.toString; }