fixing undefined originalEvent
This commit is contained in:
parent
bfe6334cd9
commit
a03d70209f
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
var prefix,
|
var prefix,
|
||||||
property,
|
property,
|
||||||
// In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior
|
// In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior
|
||||||
eventName = 'onfocusin' in document && 'hasFocus' in document ? 'focusin focusout' : 'focus blur',
|
eventName = 'onfocusin' in document && 'hasFocus' in document ? 'focusin focusout' : 'focus blur',
|
||||||
prefixes = ['', 'moz', 'ms', 'o', 'webkit'],
|
prefixes = ['', 'moz', 'ms', 'o', 'webkit'],
|
||||||
$support = $.support,
|
$support = $.support,
|
||||||
|
@ -19,12 +19,11 @@
|
||||||
|
|
||||||
$(/blur$/.test(eventName) ? window : document).on(eventName, function (event) {
|
$(/blur$/.test(eventName) ? window : document).on(eventName, function (event) {
|
||||||
var type = event.type,
|
var type = event.type,
|
||||||
originalEvent = event.originalEvent,
|
originalEvent = event.originalEvent;
|
||||||
toElement = originalEvent.toElement;
|
// If it’s a `{focusin,focusout}` event (IE), `fromElement` and `toElement` should both be `null` or `undefined`;
|
||||||
// If it’s a `{focusin,focusout}` event (IE), `fromElement` and `toElement` should both be `null` or `undefined`;
|
// else, the page visibility hasn’t changed, but the user just clicked somewhere in the doc.
|
||||||
// else, the page visibility hasn’t changed, but the user just clicked somewhere in the doc.
|
// In IE9, we need to check the `relatedTarget` property instead.
|
||||||
// In IE9, we need to check the `relatedTarget` property instead.
|
if (!/^focus./.test(type) || originalEvent == undefined || (originalEvent.toElement == undefined && originalEvent.fromElement == undefined && originalEvent.relatedTarget == undefined)) {
|
||||||
if (!/^focus./.test(type) || (toElement == undefined && originalEvent.fromElement == undefined && originalEvent.relatedTarget == undefined)) {
|
|
||||||
$event.trigger((property && document[property] || /^(?:blur|focusout)$/.test(type) ? 'hide' : 'show') + '.visibility');
|
$event.trigger((property && document[property] || /^(?:blur|focusout)$/.test(type) ? 'hide' : 'show') + '.visibility');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue