diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2024-05-01 00:54:19 +0200 |
---|---|---|
committer | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2024-05-15 00:38:40 +0200 |
commit | bb49bd794bc8ea4238162725b518fb46234f3cf9 (patch) | |
tree | db7b6152daac9f2c6b5fd051ab5d3b7ec7382791 /ui/widgets | |
parent | daa6fb55b35065c49c0ffc879c94627bbf85404c (diff) | |
download | jquery-ui-bb49bd794bc8ea4238162725b518fb46234f3cf9.tar.gz jquery-ui-bb49bd794bc8ea4238162725b518fb46234f3cf9.zip |
All: Drop support for IE & some other browsers (but mostly IE)
Closes gh-2249
Diffstat (limited to 'ui/widgets')
-rw-r--r-- | ui/widgets/accordion.js | 10 | ||||
-rw-r--r-- | ui/widgets/autocomplete.js | 48 | ||||
-rw-r--r-- | ui/widgets/button.js | 6 | ||||
-rw-r--r-- | ui/widgets/checkboxradio.js | 2 | ||||
-rw-r--r-- | ui/widgets/dialog.js | 16 | ||||
-rw-r--r-- | ui/widgets/draggable.js | 6 | ||||
-rw-r--r-- | ui/widgets/menu.js | 5 | ||||
-rw-r--r-- | ui/widgets/mouse.js | 42 | ||||
-rw-r--r-- | ui/widgets/resizable.js | 7 | ||||
-rw-r--r-- | ui/widgets/selectmenu.js | 43 | ||||
-rw-r--r-- | ui/widgets/sortable.js | 16 | ||||
-rw-r--r-- | ui/widgets/spinner.js | 29 | ||||
-rw-r--r-- | ui/widgets/tabs.js | 20 | ||||
-rw-r--r-- | ui/widgets/tooltip.js | 31 |
14 files changed, 60 insertions, 221 deletions
diff --git a/ui/widgets/accordion.js b/ui/widgets/accordion.js index d5d71224d..b6a7a7eee 100644 --- a/ui/widgets/accordion.js +++ b/ui/widgets/accordion.js @@ -187,13 +187,7 @@ return $.widget( "ui.accordion", { this._super( value ); this.element.attr( "aria-disabled", value ); - - // Support: IE8 Only - // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE - // so we need to add the disabled class to the headers and panels this._toggleClass( null, "ui-state-disabled", !!value ); - this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled", - !!value ); }, _keydown: function( event ) { @@ -611,10 +605,6 @@ return $.widget( "ui.accordion", { this._removeClass( prev, "ui-accordion-header-active" ) ._addClass( prev, "ui-accordion-header-collapsed" ); - // Work around for rendering bug in IE (#5421) - if ( toHide.length ) { - toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className; - } this._trigger( "activate", null, data ); } } ); diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js index ac2cfe42b..57e59820c 100644 --- a/ui/widgets/autocomplete.js +++ b/ui/widgets/autocomplete.js @@ -27,7 +27,6 @@ "./menu", "../keycode", "../position", - "../safe-active-element", "../version", "../widget" ], factory ); @@ -84,9 +83,9 @@ $.widget( "ui.autocomplete", { // Textareas are always multi-line // Inputs are always single-line, even if inside a contentEditable element - // IE also treats inputs as contentEditable - // All other element types are determined by whether or not they're contentEditable - this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element ); + // All other element types are determined by whether they're contentEditable + this.isMultiLine = isTextarea || + !isInput && this.element.prop( "contentEditable" ) === "true"; this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; this.isNewMenu = true; @@ -150,7 +149,6 @@ $.widget( "ui.autocomplete", { // Different browsers have different default behavior for escape // Single press can mean undo or clear - // Double press in IE means clear the whole form event.preventDefault(); } break; @@ -219,16 +217,6 @@ $.widget( "ui.autocomplete", { role: null } ) .hide() - - // Support: IE 11 only, Edge <= 14 - // For other browsers, we preventDefault() on the mousedown event - // to keep the dropdown from taking focus from the input. This doesn't - // work for IE/Edge, causing problems with selection and scrolling (#9638) - // Happily, IE and Edge support an "unselectable" attribute that - // prevents an element from receiving focus, exactly what we want here. - .attr( { - "unselectable": "on" - } ) .menu( "instance" ); this._addClass( this.menu.element, "ui-autocomplete", "ui-front" ); @@ -241,7 +229,7 @@ $.widget( "ui.autocomplete", { menufocus: function( event, ui ) { var label, item; - // support: Firefox + // Support: Firefox // Prevent accidental activation of menu items in Firefox (#7024 #9118) if ( this.isNewMenu ) { this.isNewMenu = false; @@ -279,17 +267,9 @@ $.widget( "ui.autocomplete", { previous = this.previous; // Only trigger when focus was lost (click on menu) - if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { + if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) { this.element.trigger( "focus" ); this.previous = previous; - - // #6109 - IE triggers two focus events and the second - // is asynchronous, so we need to reset the previous - // term synchronously and asynchronously :-( - this._delay( function() { - this.previous = previous; - this.selectedItem = item; - } ); } if ( false !== this._trigger( "select", event, { item: item } ) ) { @@ -608,24 +588,6 @@ $.widget( "ui.autocomplete", { // Prevents moving cursor to beginning/end of the text field in some browsers event.preventDefault(); } - }, - - // Support: Chrome <=50 - // We should be able to just use this.element.prop( "isContentEditable" ) - // but hidden elements always report false in Chrome. - // https://code.google.com/p/chromium/issues/detail?id=313082 - _isContentEditable: function( element ) { - if ( !element.length ) { - return false; - } - - var editable = element.prop( "contentEditable" ); - - if ( editable === "inherit" ) { - return this._isContentEditable( element.parent() ); - } - - return editable === "true"; } } ); diff --git a/ui/widgets/button.js b/ui/widgets/button.js index 02708d620..08a4b61c5 100644 --- a/ui/widgets/button.js +++ b/ui/widgets/button.js @@ -109,9 +109,9 @@ $.widget( "ui.button", { if ( event.keyCode === $.ui.keyCode.SPACE ) { event.preventDefault(); - // Support: PhantomJS <= 1.9, IE 8 Only - // If a native click is available use it so we actually cause navigation - // otherwise just trigger a click event + // If a native click is available use it, so we + // actually cause navigation. Otherwise, just trigger + // a click event. if ( this.element[ 0 ].click ) { this.element[ 0 ].click(); } else { diff --git a/ui/widgets/checkboxradio.js b/ui/widgets/checkboxradio.js index add80d80a..fc812116e 100644 --- a/ui/widgets/checkboxradio.js +++ b/ui/widgets/checkboxradio.js @@ -168,7 +168,7 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { // Not inside a form, check all inputs that also are not inside a form group = $( nameSelector ).filter( function() { - return $( this )._form().length === 0; + return $( $( this ).prop( "form" ) ).length === 0; } ); } diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js index cbda81636..4ba9d1117 100644 --- a/ui/widgets/dialog.js +++ b/ui/widgets/dialog.js @@ -31,8 +31,6 @@ "../focusable", "../keycode", "../position", - "../safe-active-element", - "../safe-blur", "../tabbable", "../unique-id", "../version", @@ -229,7 +227,7 @@ $.widget( "ui.dialog", { // Hiding a focused element doesn't trigger blur in WebKit // so in case we have nothing to focus on, explicitly blur the active element // https://bugs.webkit.org/show_bug.cgi?id=47182 - $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) ); + $( this.document[ 0 ].activeElement ).trigger( "blur" ); } this._hide( this.uiDialog, this.options.hide, function() { @@ -273,7 +271,7 @@ $.widget( "ui.dialog", { } this._isOpen = true; - this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) ); + this.opener = $( this.document[ 0 ].activeElement ); this._size(); this._position(); @@ -329,7 +327,7 @@ $.widget( "ui.dialog", { }, _restoreTabbableFocus: function() { - var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ), + var activeElement = this.document[ 0 ].activeElement, isActive = this.uiDialog[ 0 ] === activeElement || $.contains( this.uiDialog[ 0 ], activeElement ); if ( !isActive ) { @@ -340,11 +338,6 @@ $.widget( "ui.dialog", { _keepFocus: function( event ) { event.preventDefault(); this._restoreTabbableFocus(); - - // support: IE - // IE <= 8 doesn't prevent moving focus even with event.preventDefault() - // so we check again later - this._delay( this._restoreTabbableFocus ); }, _createWrapper: function() { @@ -427,9 +420,6 @@ $.widget( "ui.dialog", { } } ); - // Support: IE - // Use type="button" to prevent enter keypresses in textboxes from closing the - // dialog in IE (#9312) this.uiDialogTitlebarClose = $( "<button type='button'></button>" ) .button( { label: $( "<a>" ).text( this.options.closeText ).html(), diff --git a/ui/widgets/draggable.js b/ui/widgets/draggable.js index 91443fac5..e0abdd26f 100644 --- a/ui/widgets/draggable.js +++ b/ui/widgets/draggable.js @@ -25,8 +25,6 @@ "./mouse", "../data", "../plugin", - "../safe-active-element", - "../safe-blur", "../scroll-parent", "../version", "../widget" @@ -147,7 +145,7 @@ $.widget( "ui.draggable", $.ui.mouse, { }, _blurActiveElement: function( event ) { - var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ), + var activeElement = this.document[ 0 ].activeElement, target = $( event.target ); // Don't blur if the event occurred on an element that is within @@ -158,7 +156,7 @@ $.widget( "ui.draggable", $.ui.mouse, { } // Blur any element that currently has focus, see #4261 - $.ui.safeBlur( activeElement ); + $( activeElement ).trigger( "blur" ); }, _mouseStart: function( event ) { diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 1ef4b8a3d..f3fdc82c8 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -26,7 +26,6 @@ "jquery", "../keycode", "../position", - "../safe-active-element", "../unique-id", "../version", "../widget" @@ -87,7 +86,7 @@ return $.widget( "ui.menu", { }, "click .ui-menu-item": function( event ) { var target = $( event.target ); - var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) ); + var active = $( this.document[ 0 ].activeElement ); if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) { this.select( event ); @@ -131,7 +130,7 @@ return $.widget( "ui.menu", { this._delay( function() { var notContained = !$.contains( this.element[ 0 ], - $.ui.safeActiveElement( this.document[ 0 ] ) + this.document[ 0 ].activeElement ); if ( notContained ) { this.collapseAll( event ); diff --git a/ui/widgets/mouse.js b/ui/widgets/mouse.js index 1dcac5277..ef9dd8dbe 100644 --- a/ui/widgets/mouse.js +++ b/ui/widgets/mouse.js @@ -20,7 +20,6 @@ // AMD. Register as an anonymous module. define( [ "jquery", - "../ie", "../version", "../widget" ], factory ); @@ -90,12 +89,10 @@ return $.widget( "ui.mouse", { this._mouseDownEvent = event; var that = this, - btnIsLeft = ( event.which === 1 ), - - // event.target.nodeName works around a bug in IE 8 with - // disabled inputs (#7620) - elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? - $( event.target ).closest( this.options.cancel ).length : false ); + btnIsLeft = event.which === 1, + elIsCancel = typeof this.options.cancel === "string" ? + $( event.target ).closest( this.options.cancel ).length : + false; if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { return true; } @@ -141,28 +138,17 @@ return $.widget( "ui.mouse", { _mouseMove: function( event ) { // Only check for mouseups outside the document if you've moved inside the document - // at least once. This prevents the firing of mouseup in the case of IE<9, which will - // fire a mousemove event if content is placed under the cursor. See #7778 - // Support: IE <9 - if ( this._mouseMoved ) { - - // IE mouseup check - mouseup happened when mouse was out of window - if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && - !event.button ) { + // at least once. + if ( this._mouseMoved && !event.which ) { + + // Support: Safari <=8 - 9 + // Safari sets which to 0 if you press any of the following keys + // during a drag (#14461) + if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || + event.originalEvent.metaKey || event.originalEvent.shiftKey ) { + this.ignoreMissingWhich = true; + } else if ( !this.ignoreMissingWhich ) { return this._mouseUp( event ); - - // Iframe mouseup check - mouseup occurred in another document - } else if ( !event.which ) { - - // Support: Safari <=8 - 9 - // Safari sets which to 0 if you press any of the following keys - // during a drag (#14461) - if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || - event.originalEvent.metaKey || event.originalEvent.shiftKey ) { - this.ignoreMissingWhich = true; - } else if ( !this.ignoreMissingWhich ) { - return this._mouseUp( event ); - } } } diff --git a/ui/widgets/resizable.js b/ui/widgets/resizable.js index e163b03fe..1698d55e8 100644 --- a/ui/widgets/resizable.js +++ b/ui/widgets/resizable.js @@ -149,9 +149,8 @@ $.widget( "ui.resizable", $.ui.mouse, { }; this.element.css( margins ); - this.originalElement.css( "margin", 0 ); - // support: Safari + // Support: Safari // Prevent Safari textarea resize this.originalResizeStyle = this.originalElement.css( "resize" ); this.originalElement.css( "resize", "none" ); @@ -162,10 +161,6 @@ $.widget( "ui.resizable", $.ui.mouse, { display: "block" } ) ); - // Support: IE9 - // avoid IE jump (hard set the margin) - this.originalElement.css( margins ); - this._proportionallyResize(); } diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js index b1e2033ba..eecd368f5 100644 --- a/ui/widgets/selectmenu.js +++ b/ui/widgets/selectmenu.js @@ -167,12 +167,6 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, { role: "listbox", select: function( event, ui ) { event.preventDefault(); - - // Support: IE8 - // If the item was selected via a click, the text selection - // will be destroyed in IE - that._setSelection(); - that._select( ui.item.data( "ui-selectmenu-item" ), event ); }, focus: function( event, ui ) { @@ -409,20 +403,9 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, { return; } - if ( window.getSelection ) { - selection = window.getSelection(); - selection.removeAllRanges(); - selection.addRange( this.range ); - - // Support: IE8 - } else { - this.range.select(); - } - - // Support: IE - // Setting the text selection kills the button focus in IE, but - // restoring the focus doesn't kill the selection. - this.button.trigger( "focus" ); + selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange( this.range ); }, _documentClick: { @@ -442,17 +425,9 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, { // Prevent text selection from being reset when interacting with the selectmenu (#10144) mousedown: function() { - var selection; - - if ( window.getSelection ) { - selection = window.getSelection(); - if ( selection.rangeCount ) { - this.range = selection.getRangeAt( 0 ); - } - - // Support: IE8 - } else { - this.range = document.selection.createRange(); + var selection = window.getSelection(); + if ( selection.rangeCount ) { + this.range = selection.getRangeAt( 0 ); } }, @@ -643,11 +618,7 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, { _resizeMenu: function() { this.menu.outerWidth( Math.max( this.button.outerWidth(), - - // Support: IE10 - // IE10 wraps long text (possibly a rounding bug) - // so we add 1px to avoid the wrapping - this.menu.width( "" ).outerWidth() + 1 + this.menu.width( "" ).outerWidth() ) ); }, diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js index 70dc7e703..32333b6f5 100644 --- a/ui/widgets/sortable.js +++ b/ui/widgets/sortable.js @@ -24,7 +24,6 @@ "jquery", "./mouse", "../data", - "../ie", "../scroll-parent", "../version", "../widget" @@ -276,10 +275,6 @@ return $.widget( "ui.sortable", $.ui.mouse, { if ( o.cursor && o.cursor !== "auto" ) { // cursor option body = this.document.find( "body" ); - // Support: IE - this.storedCursor = body.css( "cursor" ); - body.css( "cursor", o.cursor ); - this.storedStylesheet = $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body ); } @@ -1197,11 +1192,9 @@ return $.widget( "ui.sortable", $.ui.mouse, { po.top += this.scrollParent.scrollTop(); } - // This needs to be actually done for all browsers, since pageX/pageY includes this - // information with an ugly IE fix - if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || - ( this.offsetParent[ 0 ].tagName && - this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { + // This needs to be actually done for all browsers, since pageX/pageY includes + // this information. + if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ) { po = { top: 0, left: 0 }; } @@ -1549,8 +1542,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { } //Do what was originally in plugins - if ( this.storedCursor ) { - this.document.find( "body" ).css( "cursor", this.storedCursor ); + if ( this.storedStylesheet ) { this.storedStylesheet.remove(); } if ( this._storedOpacity ) { diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index b92b8ab52..d999d85d7 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -27,7 +27,6 @@ "./button", "../version", "../keycode", - "../safe-active-element", "../widget" ], factory ); } else { @@ -131,11 +130,6 @@ $.widget( "ui.spinner", { this.previous = this.element.val(); }, blur: function( event ) { - if ( this.cancelBlur ) { - delete this.cancelBlur; - return; - } - this._stop(); this._refresh(); if ( this.previous !== this.element.val() ) { @@ -143,7 +137,7 @@ $.widget( "ui.spinner", { } }, mousewheel: function( event, delta ) { - var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ); + var activeElement = this.document[ 0 ].activeElement; var isActive = this.element[ 0 ] === activeElement; if ( !isActive || !delta ) { @@ -171,20 +165,13 @@ $.widget( "ui.spinner", { // If the input is focused then this.previous is properly set from // when the input first received focus. If the input is not focused // then we need to set this.previous based on the value before spinning. - previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ? + previous = this.element[ 0 ] === this.document[ 0 ].activeElement ? this.previous : this.element.val(); function checkFocus() { - var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ); + var isActive = this.element[ 0 ] === this.document[ 0 ].activeElement; if ( !isActive ) { this.element.trigger( "focus" ); this.previous = previous; - - // support: IE - // IE sets focus asynchronously, so we need to check if focus - // moved off of the input because the user clicked on the button. - this._delay( function() { - this.previous = previous; - } ); } } @@ -192,16 +179,6 @@ $.widget( "ui.spinner", { event.preventDefault(); checkFocus.call( this ); - // Support: IE - // IE doesn't prevent moving focus even with event.preventDefault() - // so we set a flag to know when we should ignore the blur event - // and check (again) if focus moved off of the input. - this.cancelBlur = true; - this._delay( function() { - delete this.cancelBlur; - checkFocus.call( this ); - } ); - if ( this._start( event ) === false ) { return; } diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js index 465b48cec..e191dfbb4 100644 --- a/ui/widgets/tabs.js +++ b/ui/widgets/tabs.js @@ -25,7 +25,6 @@ define( [ "jquery", "../keycode", - "../safe-active-element", "../unique-id", "../version", "../widget" @@ -171,7 +170,7 @@ $.widget( "ui.tabs", { }, _tabKeydown: function( event ) { - var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ), + var focusedTab = $( this.document[ 0 ].activeElement ).closest( "li" ), selectedIndex = this.tabs.index( focusedTab ), goingForward = true; @@ -408,18 +407,6 @@ $.widget( "ui.tabs", { if ( $( this ).is( ".ui-state-disabled" ) ) { event.preventDefault(); } - } ) - - // Support: IE <9 - // Preventing the default action in mousedown doesn't prevent IE - // from focusing the element, so if the anchor gets focused, blur. - // We don't have to worry about focusing the previously focused - // element since clicking on a non-focusable element should focus - // the body anyway. - .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() { - if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) { - this.blur(); - } } ); this.tabs = this.tablist.find( "> li:has(a[href])" ) @@ -877,10 +864,7 @@ $.widget( "ui.tabs", { _ajaxSettings: function( anchor, event, eventData ) { var that = this; return { - - // Support: IE <11 only - // Strip any hash that exists to prevent errors with the Ajax request - url: anchor.attr( "href" ).replace( /#.*$/, "" ), + url: anchor.attr( "href" ), beforeSend: function( jqXHR, settings ) { return that._trigger( "beforeLoad", event, $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) ); diff --git a/ui/widgets/tooltip.js b/ui/widgets/tooltip.js index b626c5d10..d23da1922 100644 --- a/ui/widgets/tooltip.js +++ b/ui/widgets/tooltip.js @@ -227,25 +227,20 @@ $.widget( "ui.tooltip", { content = contentOption.call( target[ 0 ], function( response ) { - // IE may instantly serve a cached response for ajax requests - // delay this call to _open so the other call to _open runs first - that._delay( function() { - - // Ignore async response if tooltip was closed already - if ( !target.data( "ui-tooltip-open" ) ) { - return; - } + // Ignore async response if tooltip was closed already + if ( !target.data( "ui-tooltip-open" ) ) { + return; + } - // JQuery creates a special event for focusin when it doesn't - // exist natively. To improve performance, the native event - // object is reused and the type is changed. Therefore, we can't - // rely on the type being correct after the event finished - // bubbling, so we set it back to the previous value. (#8740) - if ( event ) { - event.type = eventType; - } - this._open( event, target, response ); - } ); + // JQuery creates a special event for focusin when it doesn't + // exist natively. To improve performance, the native event + // object is reused and the type is changed. Therefore, we can't + // rely on the type being correct after the event finished + // bubbling, so we set it back to the previous value. (#8740) + if ( event ) { + event.type = eventType; + } + that._open( event, target, response ); } ); if ( content ) { this._open( event, target, content ); |