Skip to content

Commit

Permalink
Feature detect IE's legacy event system, since IE9 now supports DOM L…
Browse files Browse the repository at this point in the history
…2 Events.
  • Loading branch information
savetheclocktower committed Oct 5, 2010
1 parent c05412b commit a7cff52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Feature detect IE's legacy event system, since IE9 now supports DOM L2 Events. (Michael Sciacqua, kangax, Andrew Dupont)

* Fix an issue in IE9 beta where the `value` attribute of an <input> element would not get set. (Andrew Dupont)

* Move all offset methods to layout.js, eliminating some code repetition.
Expand Down
8 changes: 5 additions & 3 deletions src/dom/event.js
Expand Up @@ -85,10 +85,11 @@
var docEl = document.documentElement;
var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl
&& 'onmouseleave' in docEl;
var IE_LEGACY_EVENT_SYSTEM = (window.attachEvent && !window.addEventListener);

var _isButton;
if (Prototype.Browser.IE) {
// IE doesn't map left/right/middle the same way.
if (IE_LEGACY_EVENT_SYSTEM) {
// IE's event system doesn't map left/right/middle the same way.
var buttonMap = { 0: 1, 1: 4, 2: 2 };
_isButton = function(event, code) {
return event.button === buttonMap[code];
Expand Down Expand Up @@ -226,6 +227,7 @@
**/
function findElement(event, expression) {
var element = Event.element(event);

if (!expression) return element;
while (element) {
if (Object.isElement(element) && Prototype.Selector.match(element, expression)) {
Expand Down Expand Up @@ -363,7 +365,7 @@
return m;
});

if (Prototype.Browser.IE) {
if (IE_LEGACY_EVENT_SYSTEM) {
function _relatedTarget(event) {
var element;
switch (event.type) {
Expand Down

0 comments on commit a7cff52

Please sign in to comment.