Ensure the `target` property on events is never undefined in IE. [#383 state:resolved]
This commit is contained in:
parent
ab1313ea20
commit
91b787ae17
|
@ -1,3 +1,5 @@
|
|||
* Ensure the `target` property on events is never undefined in IE. [#383 state:resolved] (Mathias Karstädt, Diego Perini, Andrew Dupont)
|
||||
|
||||
* Ensure Element#descendants always returns an array. [#373 state:resolved] (kangax)
|
||||
|
||||
* Don't switch fixed position elements to absolute in Element.getDimensions [#543 state:resolved] (James Wheare)
|
||||
|
|
|
@ -142,18 +142,22 @@
|
|||
});
|
||||
|
||||
// IE's method for extending events.
|
||||
Event.extend = function(event) {
|
||||
Event.extend = function(event, element) {
|
||||
if (!event) return false;
|
||||
if (event._extendedByPrototype) return event;
|
||||
|
||||
event._extendedByPrototype = Prototype.emptyFunction;
|
||||
var pointer = Event.pointer(event);
|
||||
|
||||
// The optional `element` argument gives us a fallback value for the
|
||||
// `target` property in case IE doesn't give us through `srcElement`.
|
||||
Object.extend(event, {
|
||||
target: event.srcElement,
|
||||
target: event.srcElement || element,
|
||||
relatedTarget: _relatedTarget(event),
|
||||
pageX: pointer.x,
|
||||
pageY: pointer.y
|
||||
});
|
||||
|
||||
return Object.extend(event, methods);
|
||||
};
|
||||
} else {
|
||||
|
@ -171,7 +175,7 @@
|
|||
// First time we've handled this element. Put it into the cache.
|
||||
CACHE.push(element);
|
||||
registry = Element.retrieve(element, 'prototype_event_registry', $H());
|
||||
}
|
||||
}
|
||||
|
||||
var respondersForEvent = registry.get(eventName);
|
||||
if (Object.isUndefined()) {
|
||||
|
@ -195,13 +199,13 @@
|
|||
if (event.eventName !== eventName)
|
||||
return false;
|
||||
|
||||
Event.extend(event);
|
||||
Event.extend(event, element);
|
||||
handler.call(element, event);
|
||||
};
|
||||
} else {
|
||||
// Ordinary event.
|
||||
responder = function(event) {
|
||||
Event.extend(event);
|
||||
Event.extend(event, element);
|
||||
handler.call(element, event);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -229,10 +229,15 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
$('addunload').observe('click', function(e){
|
||||
if (this._done) return
|
||||
if (this._done) return;
|
||||
|
||||
window.onunload = function(){ alert('inline unload fired!') }
|
||||
Event.observe(window, 'unload', function(){ alert('observed unload fired!') })
|
||||
Event.observe(window, 'unload', function(event){
|
||||
if (!event.target) {
|
||||
alert('FAILURE: event.target should not be null!');
|
||||
}
|
||||
alert('observed unload fired!')
|
||||
});
|
||||
|
||||
this.update('Registered two unload events, one inline ("onunload") and one regular - try to refresh, both should fire')
|
||||
this._done = true
|
||||
|
|
Loading…
Reference in New Issue