TouchPolyfill icon indicating copy to clipboard operation
TouchPolyfill copied to clipboard

touchend throws null reference exception

Open ItWorksOnMyMachine opened this issue 8 years ago • 5 comments

Line 269: if (sourceEvent.type !== 'pointerdown') { oldTouch = touchesWrapper.getTouch(sourceEvent.pointerId); oldTarget = oldTouch.target; sourceEvent.target = oldTarget; }

Should be: if (sourceEvent.type !== 'pointerdown') { oldTouch = touchesWrapper.getTouch(sourceEvent.pointerId); if (oldTouch !== null && oldTouch !== undefined) { oldTarget = oldTouch.target; sourceEvent.target = oldTarget; } }

ItWorksOnMyMachine avatar Mar 14 '16 15:03 ItWorksOnMyMachine

Hi, do you have an example of where you're having an issue with this?

CamHenlin avatar Mar 15 '16 07:03 CamHenlin

+1, had the same problem.

nunodamaso avatar Mar 29 '16 16:03 nunodamaso

+1 having the same issue on Microsoft Edge (WinJS native app).

squallstar avatar May 13 '16 09:05 squallstar

Also getting undefined on touch.target here:

for (i = 0; i < touchesTouchList.length; i++) {
  touch = touchesTouchList[i];

  if (touch.target.isSameNode(thisTouchTarget)) {
    targetTouchesWrapper.addUpdateTouch(touch);
  }
}

squallstar avatar May 13 '16 10:05 squallstar

I found a solution which is to replace:

oldTarget = oldTouch.target;

by the following:

oldTarget = oldTouch ? oldTouch.target : sourceEvent.srcElement; 

samfcmc avatar Jun 21 '16 12:06 samfcmc