Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Deprecated function usage in jquery-ui #3666

Open
bytestream opened this issue Aug 12, 2020 · 16 comments
Open

Deprecated function usage in jquery-ui #3666

bytestream opened this issue Aug 12, 2020 · 16 comments

Comments

@bytestream
Copy link

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"

@blueimp
Copy link
Owner

blueimp commented Aug 13, 2020

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.

@bytestream
Copy link
Author

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

@blueimp
Copy link
Owner

blueimp commented Aug 13, 2020

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.

@bytestream
Copy link
Author

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.

@blueimp
Copy link
Owner

blueimp commented Aug 20, 2020

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.

@bytestream
Copy link
Author

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)

@blueimp
Copy link
Owner

blueimp commented Aug 22, 2020

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.

@melloware
Copy link

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

@bytestream
Copy link
Author

@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

@GedMarc
Copy link

GedMarc commented Oct 10, 2020

WWWWWHHHHAAAAAAAAAAAAAAAAAAA

@GedMarc
Copy link

GedMarc commented Oct 10, 2020

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

@GedMarc
Copy link

GedMarc commented Oct 10, 2020

image

@melloware
Copy link

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!

@baszero
Copy link

baszero commented Oct 21, 2020

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

@bytestream
Copy link
Author

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

Yes

@anders-photowall
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants