Fix issues where Firefox improperly returns the wrong node from a call to Event.element. Also fixes possible exception in Event.element in IE.

This commit is contained in:
Andrew Dupont 2008-03-28 13:13:16 -05:00
parent 0c676269e9
commit 55e5d645e1
2 changed files with 21 additions and 2 deletions

View File

@ -1,3 +1,7 @@
* Fix issues where Firefox improperly returns the wrong node from a call to Event.element. Also fixes possible exception in Event.element in IE. [jdalton, Andrew Dupont]
* Fix issue where Safari 3 deletes custom properties from the document object when the page is returned to via the back button. [mzsanford, kangax, Andrew Dupont]
* Integrate support for the W3C Selectors API into the Selector class. Will now use the API when possible (browser supports the API *and* recognizes the given selector). Means minor changes to the semantics of :enabled, :disabled, and :empty in order to comply with CSS spec.
* Avoid re-extending element in Element#getDimensions. [kangax]

View File

@ -59,8 +59,23 @@ Event.Methods = (function() {
isRightClick: function(event) { return isButton(event, 2) },
element: function(event) {
var node = Event.extend(event).target;
return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
event = Event.extend(event);
var node = eventTarget, type = event.type;
if (event.currentTarget) {
// Firefox screws up the "click" event when moving between radio buttons
// via arrow keys. It also screws up the "load" and "error" events on images,
// reporting the document as the target instead of the original image.
var currentTarget = event.currentTarget;
var tagName = currentTarget.tagName.toUpperCase();
if (['load', 'error'].include(type) ||
(tagName === 'INPUT' && currentTarget.type === 'radio' && type === 'click'))
node = currentTarget;
}
return Element.extend(node && node.nodeType == Node.TEXT_NODE ?
node.parentNode : node);
},
findElement: function(event, expression) {