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. r=crschmidt (closes #1480) (Pullup #1480)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@6763 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2008-04-02 11:53:20 +00:00
parent 67aca311a9
commit 72be27ac1b

View File

@@ -56,12 +56,24 @@ OpenLayers.Util.extend = function(destination, source) {
destination[property] = value; destination[property] = value;
} }
} }
/** /**
* IE doesn't include the toString property when iterating over an object's * IE doesn't include the toString property when iterating over an object's
* 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(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; destination.toString = source.toString;
} }
} }
@@ -510,9 +522,18 @@ OpenLayers.Util.upperCaseObject = function (object) {
* in place and returned by this function. * in place and returned by this function.
*/ */
OpenLayers.Util.applyDefaults = function (to, from) { 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) { for (var key in from) {
if (to[key] === undefined || if (to[key] === undefined ||
(from.hasOwnProperty (!fromIsEvt && from.hasOwnProperty
&& from.hasOwnProperty(key) && !to.hasOwnProperty(key))) { && from.hasOwnProperty(key) && !to.hasOwnProperty(key))) {
to[key] = from[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 * 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(from.hasOwnProperty if(!fromIsEvt && from.hasOwnProperty
&& from.hasOwnProperty('toString') && !to.hasOwnProperty('toString')) { && from.hasOwnProperty('toString') && !to.hasOwnProperty('toString')) {
to.toString = from.toString; to.toString = from.toString;
} }