Skip to content

Commit

Permalink
Merge pull request ftlabs#134 from dr-nafanya/nre-fix
Browse files Browse the repository at this point in the history
Prevent NRE after manual re-detecting the targetElement on iOS
  • Loading branch information
Matthew Caruana Galizia committed Jul 18, 2013
2 parents 280bb28 + 7565b58 commit 9ac58e3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/fastclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ FastClick.prototype.onTouchEnd = function(event) {
// See issue #57; also filed as rdar://13048589 .
if (this.deviceIsIOSWithBadTarget) {
touch = event.changedTouches[0];
targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset);
// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
}

targetTagName = targetElement.tagName.toLowerCase();
Expand Down

0 comments on commit 9ac58e3

Please sign in to comment.