🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@karan-96
Copy link
Contributor

@karan-96 karan-96 commented Jan 17, 2017

Summary

fixes issue #3475

Checklist

@mention-bot
Copy link

@karan-96, thanks for your PR! By analyzing the history of the files in this pull request, we identified @davids549, @gibson042 and @flesler to be potential reviewers.

@mgol
Copy link
Member

mgol commented Jan 18, 2017

Thanks for the PR. However, more things are needed for this to land:

  1. jQuery.nodeName has to stop being used internally; its definition has to be extracted to a separate AMD module under src/core/var/nodeName.js and included via AMD where needed; the jQuery.nodeName definition should be reduced to something like:
define( [
	/* other code */
	"./core/var/nodeName"
], function ( /* other code */ nodeName ) {

"use strict";

/* other code */

jQuery.nodeName = nodeName;

} );
  1. Tests for jQuery.nodeName have to be moved to test/unit/deprecated.js as well.

You can see 1b9575b for what was needed for the jQuery.isArray deprecation; similar actions will be needed here with the exception that the deprecated method is this time not 100% equivalent to a native one so we still need to keep the code in a separate module (in src/core/var/nodeName.js that you need to create as I mentioned).

Would you like to apply those changes? If you have any doubts about what has to be done just ask.

@karan-96
Copy link
Contributor Author

yes i would like to work on this.

@mgol mgol removed the Needs info label Jan 18, 2017
@mgol
Copy link
Member

mgol commented Jan 18, 2017

Cool! Let us know if you stumble upon any problems.

@karan-96
Copy link
Contributor Author

@mgol sir, my 'src/core/var/nodeName.js' looks like

define(function( elem, name ) {
	"use strict";

	return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
} );

and i need to include its definition(the one you mentioned above) via AMD everywhere jQuery.nodeName has been used. Am i getting your 1st point correct?

@mgol
Copy link
Member

mgol commented Jan 23, 2017

@karan-96 The function passed to define defines a module that should return what you want to export so you need to wrap your function in another. Look at https://github.com/jquery/jquery/blob/3.1.1/src/css/addGetHookIf.js for how it can be done.

Also, now that I look at it it probably doesn't have to be a var-module so you can put it in src/core/nodeName.js instead of src/core/var/nodeName.js.

@karan-96
Copy link
Contributor Author

@mgol sir,
1.How can I include nodeName function in /test files? I tried “define” like I did in /src files but i found errors when I built jquery. So after exploring the directory I found “test/.eslintrc.json”. And I found “define” : “false” there under globals option. Is it because of this that I am not able to use “define”? And How should I proceed now?

2.And do i have to write a new test for nodeName and include it in deprecate.js?

@mgol
Copy link
Member

mgol commented Jan 27, 2017

@karan-96 In tests just use jQuery.nodeName; we're testing what is publicly exposed, not private modules. Also, you don't have to write any tests, just find exsiting ones and move them to test/unit/deprecated.js.

@karan-96 karan-96 force-pushed the #3475-deprecate-jquery.nodeName branch from 09e5246 to 5ec2bcd Compare January 27, 2017 19:35
@mgol
Copy link
Member

mgol commented Feb 13, 2017

@karan-96 Do you think you'll have time to move the unit tests soon?

@mgol mgol self-assigned this Feb 13, 2017
@karan-96
Copy link
Contributor Author

@mgol ,i did not find any test for jquery.nodeName. please tell me if i am missing something?

@mgol
Copy link
Member

mgol commented Feb 13, 2017

@karan-96 You're right, this is a private API so there was no tests for it.

A couple remarks:

  1. Could you rebase this PR over latest master? There is a minor conflict in src/deprecated.js.
  2. After you rebase you should notice a few extra uses of jQuery.nodeName in src/traversing.js.
  3. I was wrong that you can just use jQuery.nodeName in tests, sorry for that. We'll want to remove the method one day and it being used in tests will be problematic. All the mentions should be replace by bare elem.nodeName, sometimes passed through toLowerCase() but not always - you can verify if you replaced it incorrectly when you run the tests.
  4. I've noticed you added the entries for nodeName in the dependencies lists of various modules to the end of the list. They should be placed near other entries for the same module, e.g. in src/offset.js the entry "./core/nodeName" should be placed after "./core/access" not "./css/support".

Could you apply those changes?

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply the changes I mentioned in my last comment.

@karan-96
Copy link
Contributor Author

yes , i will apply these changes.

@karan-96 karan-96 force-pushed the #3475-deprecate-jquery.nodeName branch from e56c8e1 to a4ad702 Compare February 16, 2017 11:27
@karan-96
Copy link
Contributor Author

@mgol sir i have applied the changes.please review them ?

Copy link
Member

@timmywil timmywil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more change! Thanks!

}
},
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one thing left in my mind. Import src/core/nodeName.js in this file and set nodeName: nodeName rather than writing the function twice.

@timmywil timmywil added this to the 3.2.0 milestone Feb 27, 2017
@timmywil timmywil added this to the 3.2.0 milestone Feb 27, 2017
@mgol mgol closed this in ac9e301 Mar 1, 2017
@mgol
Copy link
Member

mgol commented Mar 1, 2017

Landed, thanks @karan-96!

@karan-96
Copy link
Contributor Author

karan-96 commented Mar 7, 2017

thank you all for your guidance throughout.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants