Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Work around IE bug related to relatedTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Mar 12, 2014
1 parent ceabcc8 commit dccf0c6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/wrappers/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,20 @@

if ('relatedTarget' in event) {
var originalEvent = unwrap(event);
var unwrappedRelatedTarget = originalEvent.relatedTarget;

// X-Tag sets relatedTarget on a CustomEvent. If they do that there is no
// 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.
if (originalEvent.relatedTarget) {
var relatedTarget = wrap(originalEvent.relatedTarget);

// 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)
Expand Down

0 comments on commit dccf0c6

Please sign in to comment.