2.6 introduced a regression that maps could not be created when the Object

prototype is extended. Although OpenLayers is not designed to work when this
fundamental violation of Javascript is in place, we can at least not fail
so miserably in this case: this gets us back to a similar level of 
functionality as we had in 2.5. This was brought up by a user working on 
a viamichelin layer, which apparently extends the object prototype (bad!),
and fixed in conjuction with tschaub. r=pgiraud,tschaub (Pullup #1502)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@6832 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-04-09 16:06:23 +00:00
parent cadc54cc4e
commit ffab22ba19
3 changed files with 25 additions and 1 deletions

View File

@@ -532,7 +532,9 @@ OpenLayers.Events = OpenLayers.Class({
*/
register: function (type, obj, func) {
if (func != null) {
if (func != null &&
((this.eventTypes && OpenLayers.Util.indexOf(this.eventTypes, type) != -1) ||
OpenLayers.Util.indexOf(this.BROWSER_EVENTS, type) != -1)) {
if (obj == null) {
obj = this.object;
}

21
tests/Extras.html Normal file
View File

@@ -0,0 +1,21 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;
// Ensure that we continue to work if silly Javascript frameworks
// extend object.
Object.prototype.foo = function() { }
function test_Events_Object_Extension(t) {
t.plan(1)
map = new OpenLayers.Map("map");
t.ok("Map created if object prototype is extended.");
}
</script>
</head>
<body>
<div id="map" style="width: 600px; height: 300px;"/>
</body>
</html>

View File

@@ -1,5 +1,6 @@
<ul id="testlist">
<li>OpenLayers.html</li>
<li>Extras.html</li>
<li>Ajax.html</li>
<li>BaseTypes.html</li>
<li>BaseTypes/Bounds.html</li>