From 9724bbaeeebfc661f16043feb0df0b1f7fe5e5e8 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 13 Sep 2007 23:17:44 +0000 Subject: [PATCH] Here we have finally solved the smashing of the Event object problem. Once and forall. God save the queen when 3.0 comes we're getting rid of this sloppiness. See r4040 for more info on why we've done all this. (Closes #880) git-svn-id: http://svn.openlayers.org/trunk/openlayers@4271 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Events.js | 6 ++++-- tests/test_Events.html | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index bbfb846302..e293bcdef0 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -326,8 +326,10 @@ OpenLayers.Event.observe(window, 'unload', OpenLayers.Event.unloadCache, false); // FIXME: Remove this in 3.0. In 3.0, Event.stop will no longer be provided // by OpenLayers. -if (!window.Event) { - var Event = OpenLayers.Event; +if (window.Event) { + OpenLayers.Util.applyDefaults(window.Event, OpenLayers.Event); +} else { + var Event = OpenLayers.Event; } /** diff --git a/tests/test_Events.html b/tests/test_Events.html index 729b2851df..57cb5c50f1 100644 --- a/tests/test_Events.html +++ b/tests/test_Events.html @@ -332,6 +332,11 @@ t.eq( events.listeners["doThingA"].length, 1, "event type passed to addEventType correctly does nothing if clashes with already defined event type" ); } + /** HACK HACK HACK Deprecated This test should be removed in 3.0 **/ + function test_Events_globalEventObject(t) { + t.plan(1); + t.ok(Event.stop, "a stop() function exists on the global JS Event object, if indeed it exists. This is legacy deprecated and will be gone in 3.0"); + }