diff --git a/CHANGELOG b/CHANGELOG index 2faa7e5..4e42982 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *1.6.0_rc1* (October 16, 2007) +* Fix Event#is(Left|Middle|Right)Click in IE. Closes #7520 (again). [Mislav Marohnić] + * Ensure Event.* generic methods work in IE, even when the event is not extended. [Viktor Kojouharov, Andrew Dupont] * Don't translate "keypress" events into "keydown" events. [sam] diff --git a/src/event.js b/src/event.js index 6c7ce63..b516b98 100644 --- a/src/event.js +++ b/src/event.js @@ -30,24 +30,27 @@ Object.extend(Event, { }); Event.Methods = (function() { + var isButton; + if (Prototype.Browser.IE) { - function isButton(event, code) { - return event.button == ({ 0: 1, 1: 4, 2: 2 })[code]; - } + var buttonMap = { 0: 1, 1: 4, 2: 2 }; + isButton = function(event, code) { + return event.button == buttonMap[code]; + }; } else if (Prototype.Browser.WebKit) { - function isButton(event, code) { + isButton = function(event, code) { switch (code) { case 0: return event.which == 1 && !event.metaKey; case 1: return event.which == 1 && event.metaKey; default: return false; } - } + }; } else { - function isButton(event, code) { + isButton = function(event, code) { return event.which ? (event.which === code + 1) : (event.button === code); - } + }; } return {