Skip to content

Commit 3a1b590

Browse files
Update cancel check to be shadowRoot compatible
This proposal is made to correctly check if the event should be canceled if the first element in the composedPath (or the event.target) matches with the options.cancel selector
1 parent e21a254 commit 3a1b590

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ui/widgets/mouse.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ return $.widget( "ui.mouse", {
7373
}
7474
},
7575

76+
/**
77+
*
78+
* @param {MouseEvent & { originalEvent: MouseEvent }} event
79+
* @returns {boolean}
80+
*/
7681
_mouseDown: function( event ) {
7782

7883
// don't let more than one widget handle mouseStart
@@ -89,13 +94,15 @@ return $.widget( "ui.mouse", {
8994

9095
this._mouseDownEvent = event;
9196

97+
let [ first = event.target ] = 'composedPath' in event.originalEvent && event.originalEvent.composedPath() || []
98+
9299
var that = this,
93100
btnIsLeft = ( event.which === 1 ),
94101

95102
// event.target.nodeName works around a bug in IE 8 with
96103
// disabled inputs (#7620)
97-
elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
98-
$( event.target ).closest( this.options.cancel ).length : false );
104+
elIsCancel = ( typeof this.options.cancel === "string" && first.nodeName ?
105+
$( first ).closest( this.options.cancel ).length : false );
99106
if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
100107
return true;
101108
}

0 commit comments

Comments
 (0)