blueimp/jQuery-File-Upload

Deprecated function usage in jquery-ui

Opened this issue · 16 comments

There's been some work towards removing deprecated function usage over the last few months. It seems the below haven't been pointed out before, so here goes:

jQuery.isArray is deprecated; use Array.isArray

jQuery. isFunction() is deprecated. In most cases, its use can be replaced by typeof x === "function"

Thanks for your recommendation @bytestream.

Unfortunately, Array.isArray is only supported by IE9+ and more modern browsers, but I aim to keep the original browser compatibility guarantees of this project, which still supports older browsers and works with jQuery 1.7+.

It's likely that this project will stop supporting newer jQuery versions at some point.

jquery.ui.widget.js is mostly a copy of the original version from the jQuery UI project with some patches, but I prefer to keep changes minimal to ease merging upstream fixes.

Thanks for the update. I think the Mozilla polyfill should allow you to keep the version guarantee? I've sent that to a few other projects like jquery-validation and DataTables

Well, that would introduce a breaking change that seems unnecessary to me.

From my perspective, one of jQuery's greatest strengths has always been smoothing out browser differences (together with providing better APIs for XHR requests and DOM manipulation).

Most modern frontend projects that only support modern browsers will likely not use jQuery, nor have a need for this project.

I'm still planning to support modern jQuery versions, but since these are only deprecation messages, I don't think it's worth it to add a breaking change that requires adding more boilerplate code at this point.

Sorry I missed this. Why would the polyfill introduce a breaking change?

The below polyfill (from Mozilla) supports all browser versions, and does not break support where Array.isArray already exists.

if (!Array.isArray) {
  Array.isArray = function(arg) {
    return Object.prototype.toString.call(arg) === '[object Array]';
  };
}

My suggestion is to add the polyfill to this library.

If we add the polyfill to the library, it would not be a breaking change.

I don't think it's good practice to add polyfills in unrelated libraries.
Even if we would do it regardless, which library file should include the polyfill code and where in the code should the polyfill be executed?
If we should do this, it should be a separate file with polyfill in the name and therefore a breaking change.

I don't think it's good practice to add polyfills in unrelated libraries.

Could ponyfill instead. Just a local (private) method:

  var isArray = function(arg) {
    return Object.prototype.toString.call(arg) === '[object Array]';
  };

Given it's currently only needed by jQuery-ui, dump it in that file.

jquery.ui.widget.js is mostly a copy of the original version from the jQuery UI project with some patches, but I prefer to keep changes minimal to ease merging upstream fixes.

I don't think there are likely to be any further changes coming from upsteam. jQuery-ui is marked as dead - I alluded to it here: #3504 (comment)

Thanks for the reminder about jQuery UI's end-of-life.

Adding a local isArray function is definitely an option. It's used across four files though:

paramNames = $.isArray(options.paramName)

if (data.result && $.isArray(data.result.files)) {

if ($.isArray(prototype)) {

if ($.isArray(options.formData)) {

} else if (!$.isArray(paramName)) {

So making it sharable would be beneficial, although the Iframe Transport and jQuery Widget Library are very much independent pieces.

Jquery UI is alive and is getting active attention in fact they just updated all of their code to remove all these deprecated methods.

And they are planning a 1.13 release: https://github.com/jquery/jquery-ui/pulls?q=is%3Apr+is%3Aclosed

@melloware Something must have changed recently then given it was? listed emeritus by the openjs foundation and there's been no release since 2016

Pleased to see an injection of life nonetheless

WWWWWHHHHAAAAAAAAAAAAAAAAAAA

Looks like they started 4 days (meaning so far one person), but that's a lot of updates for day 1......
wonder if he/she/it is actually part of the original crew, and how many are on it 👍

this is good news

Yeah I monitor UI and mgol has been doing lots of updates this year in prep for 1.13 including removing all deprecated API usage and making sure it passes with he jquery migrate plugin!

Does this plugin work with jQuery 3.5.1 and jQuery-UI 1.12.1?

Does this plugin work with jQuery 3.5.1 and jQuery-UI 1.12.1?

Yes

So I just stumbled upon this as I'm working with upgrading jQuery in a project. Seems that the 1.13 version of jquery-ui might actually come soon, an alpha was released 6 days ago: https://github.com/jquery/jquery-ui/releases