-
Notifications
You must be signed in to change notification settings - Fork 20.6k
v2.1.4 isArrayLike empty obj error #2242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The documentation for jQuery.map doesn't say the method takes a string, but you're passing one in the case where the |
This change also breaks DataTables as it has the following code:
|
That should be fixed in the plugin, since |
I don't disagree that the plugin should fix their incorrect usage, but should a minor point release of jQuery introduce such a backwards-incompatible change? Seeing as it breaks a very popular plugin, and countless other codebases that rely on the previous behaviour… |
@Drarok Technically speaking, semver only describes the relation between a public API and versions and here we're talking about undocumented behavior therefore semver doesn't apply. Unfortunately, such problems are unavoidable. People don't remember all possible method signatures and don't check the docs on every use which leads to sometimes relying on undocumented behavior. Any change we make, even in patch releases may break some of those invalid use cases, that's why we always say semver is just a hint but you should test your projects on every library upgrade, even if you just upgrade to a newer patch release. Thus, the question is not if we broke some plugin that uses undocumented APIs incorrectly (I'd guess we almost always break something) but how much impact such breakage may have, e.g. how popular is a plugin etc. If anyone reported the issue with the patch in PR #2185 we'd most likely update the patch to avoid this issue but it's done, we've released
Whatever happens, you'll need to update one of the libraries anyway to make it work. In this case I'd rather DataTables fixed their incorrect use of the jQuery API. Did you report this issue to them? If they have a public bug tracker, could you post a link here? I'd say we should work around it & release a new patch update only if a lot of popular plugins relied on this behavior. So far we only know about one and they should IMO just fix it on their side. |
Well said, @mzgol. There would have to be quite an uproar for us to do another patch release to support undocumented behavior. |
I posted about the problem on their forums: |
The fix has been committed to DataTables now and its nightly version is up to date with the change. Passing a string is was a bug that I didn't pick up before as it "just worked" in jQuery before so I didn't notice it! I completely concur that no change should be required in jQuery!
DataTables is MIT licensed :-) |
Sorry, my quick glance at the site was not enough apparently. :)
I fully understand, such issues are unavoidable, unfortunately. Thanks for a quick reaction! |
Hm, should we add this behaviour to the migrate? |
Seems like a good idea. |
I would say no. We only care about changes to documented behavior. |
@gibson042 we did it a lot for undocumented behaviour and undocumented methods, for example - https://github.com/jquery/jquery-migrate/blob/920afc6637645629e8cc22c9b76cd2fdc59e0d96/src/manipulation.js |
Attempting to use DataTables in a project and I am still receiving this error. I have attached my plunker, When you change the jquery version to 1.8.3 in the cdn link in the html all works well, if you leave as 2.1.4 and view the developer tools you see the following: |
The first Google result for "jquery isarraylike datatables" is this ticket: Have you updated your DataTables plugin? |
yes, I have even tried using the nightlies in the cdn. |
Then you should report the problem to the DataTables team. |
Sorry, thought this was the DataTables issue. Posted in wrong tab. |
I received this error
Uncaught TypeError: Cannot use 'in' operator to search for 'length' in
When trying to call
$.map
like so:$.map("".match( /"[^"]+"|[^ ]+/g ) || "", function(word) {console.log(word);});
It seems that
"length" in obj
returns the error when theobj == ""
, but it works fine whenobj == [""]
I just want to check that passing in the
obj == [""]
should be what I do moving forward. Thanks!The text was updated successfully, but these errors were encountered: