From 0725a1ca5175ccd7cc6652300fc5c0f70b651a8c Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Fri, 14 Mar 2014 10:38:23 -0400 Subject: [PATCH] IE & relatedTarget again PR #401 was not complete. My intention was to set the relatedTarget to null if we run into one of these invalid relatedTargets. --- src/wrappers/events.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/wrappers/events.js b/src/wrappers/events.js index 929f5c0..506ac69 100644 --- a/src/wrappers/events.js +++ b/src/wrappers/events.js @@ -276,19 +276,20 @@ // way to have relatedTarget return the adjusted target but worse is that // the originalEvent might not have a relatedTarget so we hit an assert // when we try to wrap it. - - // In IE we can get objects that are not EventTargets at this point. - // Safari does not have an EventTarget interface so revert to checkin for - // addEventListener as an approximation. - - if (unwrappedRelatedTarget && unwrappedRelatedTarget instanceof Object && - unwrappedRelatedTarget.addEventListener) { - var relatedTarget = wrap(unwrappedRelatedTarget); - - var adjusted = adjustRelatedTarget(currentTarget, relatedTarget); - if (adjusted === target) - return true; - + if (unwrappedRelatedTarget) { + // In IE we can get objects that are not EventTargets at this point. + // Safari does not have an EventTarget interface so revert to checking + // for addEventListener as an approximation. + if (unwrappedRelatedTarget instanceof Object && + unwrappedRelatedTarget.addEventListener) { + var relatedTarget = wrap(unwrappedRelatedTarget); + + var adjusted = adjustRelatedTarget(currentTarget, relatedTarget); + if (adjusted === target) + return true; + } else { + adjusted = null; + } relatedTargetTable.set(event, adjusted); } }