-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Fix for #2808; inconsistent .not/.filter #2809
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
|
By analyzing the blame information on this pull request, we identified @gibson042, @timmywil and @markelog to be potential reviewers |
|
Thank you for your pull request. It looks like this may be your first contribution to a jQuery Foundation project, if so we need you to sign our Contributor License Agreement (CLA). 📝 Please visit http://contribute.jquery.org/CLA/ to sign. After you signed, the PR is checked again automatically after a minute. If there's still an issue, please reply here to let us know. If you've already signed our CLA, it's possible your git author information doesn't match your CLA signature (both your name and email have to match), for more information, check the status of your CLA check. |
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.
the cheaper check should be evaled first
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.
It may be a cheaper check on it's own, but it's a far less discriminating check in most use cases as it would only ever be false when using non-element nodes.
As far as I know, only the .contents() function can return non-element nodes, so not a very common situation.
Placing the nodeType check last would shortcut it in most cases.
Placing the nodeType check first would mean both checks would have to be evaluated in most cases.
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.
True, the nodeType check is pretty rarely going to fail so the order isn't too important here.
Inconsistent ehaviour for non-element nodes when using multiple recursive pseudo-selectors on `*` in `.not()` and `.filter()`.
|
The code change looks good, but it needs |
|
Unittests should be simple enough. |
|
Added two unittests which cover the issue. |
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.
Can you combine these tests together into something like "not(Selector) excludes non-element nodes (gh-2808)", and use simpler selectors? E.g.,
var mixedContents = jQuery( "#nonnodes" ).contents(),
childElements = q( "nonnodesElement" );
assert.deepEqual( mixedContents.not( "*" ).get(), [], "not *" );
assert.deepEqual( mixedContents.not( "[id=a],[id=b]" ).get(), childElements, "not [id=a],[id=b]" );
assert.deepEqual( mixedContents.not( "[id=a],*,[id=b]" ).get(), [], "not [id=a],*,[id=b]" );
Inconsistent ehaviour for non-element nodes when using multiple recursive pseudo-selectors on
*in.not()and.filter().Fixes gh-2808