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,12 +1620,18 @@
if ( $.MouseTracker.havePointerCapture ) { if ( $.MouseTracker.havePointerCapture ) {
if ( $.MouseTracker.havePointerEvents ) { if ( $.MouseTracker.havePointerEvents ) {
if ( $.MouseTracker.unprefixedPointerEvents ) { // Can throw InvalidPointerId
tracker.element.setPointerCapture( gPoint.id ); // (should never happen for setPointerCapture so we'll log a warning)
//$.console.log('element.setPointerCapture() called'); try {
} else { if ( $.MouseTracker.unprefixedPointerEvents ) {
tracker.element.msSetPointerCapture( gPoint.id ); tracker.element.setPointerCapture( gPoint.id );
//$.console.log('element.msSetPointerCapture() called'); //$.console.log('element.setPointerCapture() called');
} else {
tracker.element.msSetPointerCapture( gPoint.id );
//$.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 );
@ -1674,12 +1680,19 @@
if ( $.MouseTracker.havePointerCapture ) { if ( $.MouseTracker.havePointerCapture ) {
if ( $.MouseTracker.havePointerEvents ) { if ( $.MouseTracker.havePointerEvents ) {
if ( $.MouseTracker.unprefixedPointerEvents ) { // Can throw InvalidPointerId
tracker.element.releasePointerCapture( gPoint.id ); // (can happen depending on browser event timing (Firefox touch)
//$.console.log('element.releasePointerCapture() called'); // so we won't log a warning)
} else { try {
tracker.element.msReleasePointerCapture( gPoint.id ); if ( $.MouseTracker.unprefixedPointerEvents ) {
//$.console.log('element.msReleasePointerCapture() called'); tracker.element.releasePointerCapture( gPoint.id );
//$.console.log('element.releasePointerCapture() called');
} else {
tracker.element.msReleasePointerCapture( gPoint.id );
//$.console.log('element.msReleasePointerCapture() called');
}
} catch ( e ) {
/* eslint-disable no-empty */
} }
} else { } else {
tracker.element.releaseCapture(); tracker.element.releaseCapture();