-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Core: Don't rely on splice being present on input #4986
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
Conversation
Without this fix it does that TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Reproduced here: https://jsbin.com/gocusihafe/1/edit?html,css,js,console,output
|
Thanks for opening a pull request! It seems we forgot to change our use of splice when removing it from the jQuery object. We did take care of sort and push, just not splice. I'm surprised our tests didn't catch this, but we're going to need to add a test. Something like the case in the jsbin will work fine to get duplicates on the jQuery object (i.e. Also, splice should be its own var file, just like with sort Thanks! |
@bubbatls Hey, are you interested in addressing Timmy's concerns? |
@bubbatls Ping. This looks like an issue we'd like to see fixed but to land your PR we need to have Timmy's concerns addressed. If you don't have time for this, please let us know and we'll likely fix this by ourselves. |
I'm sorry, I was in holiday and after holidays there is a lot of work to do... Thanks |
@bubbatls Sure, no problem. Let us know if you hit any roadblocks. |
Fixed by creating a var file for splice as for other Array methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good now but we still need a test. Can you add one?
@timmywil BTW, I think we can have a simpler & more direct test:
jQuery.uniqueSort( { 0: div, 1: div, length: 2 } );
where div
is a test div appended to #qunit-fixture
. What do you think? Or maybe we can add both test cases.
yes, the test you write is the most unit one about this issue, and the method name is uniqueSort so, checking the "unique" is completely relevant. But I agree that another one covering more code by doing the .find('div').find('div') is worth being written for potential future regression. This test should be written in the test/unit/selector.js file? |
Yes, the both tests should be written in EDIT: I made a typo and I mentioned |
I'm sorry but I spend some time to try to understand how to run the tests before modifying anything. But I have always the error : |
How are you running the tests? You need to build before running the tests as the build process creates a few test files and also builds jQuery and the built version is what gets tested by default. Run |
There was a bug in the test the input was modified to the good result before the second way of testing with not true Array object.
Thank you, I'm sorry I'm new to npm. In fact there was a bug in an existing unit test for all that. So I've fixed it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some style nits but otherwise looks good, thanks! It's nice you found an existing broken test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. Thanks for the tests.
Nice! thanks you all :) |
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix calling `jQuery.uniqueSort` on an array-like can result in: TypeError: results.splice is not a function at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12) at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27) at gocusihafe.js:3:4 Ref jquerygh-4986
Without this fix it does that
TypeError: results.splice is not a function
at Function.jQuery.uniqueSort (https://code.jquery.com/jquery-git.js:664:12)
at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2394:27)
at gocusihafe.js:3:4
Reproduced here:
https://jsbin.com/gocusihafe/1/edit?html,css,js,console,output
Summary
Checklist