From cbaec757e2064d53466aea82c2ca25238ce84004 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Tue, 7 Aug 2007 14:55:34 +0000 Subject: [PATCH] Prototype: Fix event extensions and custom events firing for Safari 2.0 --- CHANGELOG | 2 ++ src/event.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 03e9737..13bce6e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix event extensions and custom events firing for Safari 2.0. [Thomas Fuchs] + * Add RegExp.escape for escaping regular expression strings. Closes #9094. [Ken Snyder] * Make the eventName and handler arguments to Event.stopObserving optional. If no handler is specified, all handlers for the given event are unregistered. If no event name is specified, all observed events on the element are unregistered. [sam] diff --git a/src/event.js b/src/event.js index 6016c76..0c209e5 100644 --- a/src/event.js +++ b/src/event.js @@ -99,7 +99,14 @@ Event.extend = (function() { }; } else { - Event.prototype = Event.prototype || document.createEvent("Events").__proto__; + if(!Event.prototype) try { + Event.prototype = document.createEvent("Events").__proto__; + } catch(e) { + return function(event) { + if (event._extendedByPrototype) return event; + return Object.extend(event, methods); + }; + } Object.extend(Event.prototype, methods); return Prototype.K; } @@ -212,7 +219,11 @@ Object.extend(Event, (function() { element = document.documentElement; if (document.createEvent) { - var event = document.createEvent("Events"); + try { + var event = document.createEvent("Events"); + } catch(e) { + var event = document.createEvent("UIEvents"); + } event.initEvent("dataavailable", true, true); } else { var event = document.createEventObject();