Ticket #2495 (new bug)
Opened 3 years ago
Event object conflict with Prototype in Internet Explorer
| Reported by: | gingerbbm | Owned by: | tschaub |
|---|---|---|---|
| Priority: | major | Milestone: | 2.13 Release |
| Component: | Events | Version: | 2.8 |
| Keywords: | Internet Explorer, window.Event, conflict, Prototype.js | Cc: | |
| State: |
Description
There is an Event object conflict in the specific case of inluding OpenLayers.js after Prototype.js in Internet Explorer versions 6, 7 and 8. Under http://trac.openlayers.org/ticket/880 the following fix was made:
// FIXME: Remove this in 3.0. In 3.0, Event.stop will no longer be provided
// by OpenLayers.
if (window.Event) {
OpenLayers.Util.applyDefaults(window.Event, OpenLayers.Event);
} else {
var Event = OpenLayers.Event;
}
For some reason, window.Event is undefined in IE when this code is hit. I put together the following test that loads each library script in the requisite order, testing for window.Event and Event.pointerX before each load:
window.Event appears to be available throughout, but in Events3.js it suddenly isn't. (I split Events.js into four separate files when homing in on the problem and added one line to Events3.js to check for the prescence of window.Event.) This results in window.Event being overwritten and consequently methods like Event.pointerX() become unavailable.
As the comment in the code says, "Remove this in 3.0". In cursory checks removing this code at 2.8 appears to be OK but being unfamiliar with a lot of the features of OL I don't know how risky this is.
I initially posted this information to the mailing list at http://n2.nabble.com/OpenLayers-and-Prototype-conflict-in-IE-td4591037.html#a4591037.
I'm using OpenLayers 2.8.
