setPointerCapture/releasePointerCapture exception handling

This commit is contained in:
Mark Salsbery 2020-08-25 08:51:00 -07:00
parent c22e624a3d
commit 5360e65ee9

View File

@ -1620,6 +1620,9 @@
if ( $.MouseTracker.havePointerCapture ) { if ( $.MouseTracker.havePointerCapture ) {
if ( $.MouseTracker.havePointerEvents ) { if ( $.MouseTracker.havePointerEvents ) {
// Can throw InvalidPointerId
// (should never happen for setPointerCapture so we'll log a warning)
try {
if ( $.MouseTracker.unprefixedPointerEvents ) { if ( $.MouseTracker.unprefixedPointerEvents ) {
tracker.element.setPointerCapture( gPoint.id ); tracker.element.setPointerCapture( gPoint.id );
//$.console.log('element.setPointerCapture() called'); //$.console.log('element.setPointerCapture() called');
@ -1627,6 +1630,9 @@
tracker.element.msSetPointerCapture( gPoint.id ); tracker.element.msSetPointerCapture( gPoint.id );
//$.console.log('element.msSetPointerCapture() called'); //$.console.log('element.msSetPointerCapture() called');
} }
} catch ( e ) {
$.console.warn('setPointerCapture() called on invalid pointer ID');
}
} else { } else {
tracker.element.setCapture( true ); tracker.element.setCapture( true );
//$.console.log('element.setCapture() called'); //$.console.log('element.setCapture() called');
@ -1674,6 +1680,10 @@
if ( $.MouseTracker.havePointerCapture ) { if ( $.MouseTracker.havePointerCapture ) {
if ( $.MouseTracker.havePointerEvents ) { if ( $.MouseTracker.havePointerEvents ) {
// Can throw InvalidPointerId
// (can happen depending on browser event timing (Firefox touch)
// so we won't log a warning)
try {
if ( $.MouseTracker.unprefixedPointerEvents ) { if ( $.MouseTracker.unprefixedPointerEvents ) {
tracker.element.releasePointerCapture( gPoint.id ); tracker.element.releasePointerCapture( gPoint.id );
//$.console.log('element.releasePointerCapture() called'); //$.console.log('element.releasePointerCapture() called');
@ -1681,6 +1691,9 @@
tracker.element.msReleasePointerCapture( gPoint.id ); tracker.element.msReleasePointerCapture( gPoint.id );
//$.console.log('element.msReleasePointerCapture() called'); //$.console.log('element.msReleasePointerCapture() called');
} }
} catch ( e ) {
/* eslint-disable no-empty */
}
} else { } else {
tracker.element.releaseCapture(); tracker.element.releaseCapture();
//$.console.log('element.releaseCapture() called'); //$.console.log('element.releaseCapture() called');