Event#element clean-up.
This commit is contained in:
parent
b7af8a745b
commit
be8508f2a1
21
src/event.js
21
src/event.js
@ -61,21 +61,22 @@ Event.Methods = (function() {
|
||||
element: function(event) {
|
||||
event = Event.extend(event);
|
||||
|
||||
var node = event.target, type = event.type;
|
||||
var node = event.target,
|
||||
type = event.type,
|
||||
currentTarget = event.currentTarget,
|
||||
tagName = currentTarget.tagName;
|
||||
|
||||
if (event.currentTarget && event.currentTarget.tagName) {
|
||||
if (currentTarget && tagName) {
|
||||
// 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;
|
||||
if (type === 'load' || type === 'error' ||
|
||||
(type === 'click' && tagName.toLowerCase() === 'input'
|
||||
&& currentTarget.type === 'radio'))
|
||||
node = currentTarget;
|
||||
}
|
||||
|
||||
return Element.extend(node && node.nodeType == Node.TEXT_NODE ?
|
||||
node.parentNode : node);
|
||||
if (node.nodeType == Node.TEXT_NODE) node = node.parentNode;
|
||||
return Element.extend(node);
|
||||
},
|
||||
|
||||
findElement: function(event, expression) {
|
||||
|
Loading…
Reference in New Issue
Block a user