api.jquery.com icon indicating copy to clipboard operation
api.jquery.com copied to clipboard

'Selector' type ambiguous

Open leonard-thieu opened this issue 7 years ago • 6 comments

From the Types page:

If Selector is specified as the type of an argument, it accepts everything that the jQuery constructor accepts, eg. Strings, Elements, Lists of Elements.

The jQuery constructor accepts Selector, Element, Array, PlainObject, and jQuery.

The definitions are conflicting. Does Selector really mean String when it's used throughout documentation or is the selector argument supposed to be of type String instead of Selector?

leonard-thieu avatar Jun 07 '17 15:06 leonard-thieu

A Selector string is a specific type of string that is a valid CSS selector. Note that the jQuery constructor also accepts other strings that represent HTML markup, which we distinguish by how they "look".

What it's saying is that you can pass either a selector string or an element itself, for example jQuery("body"), jQuery(document.body), and jQuery([ document.body ]) all get you the same collection. However, jQuery("<body>") is not the same thing, it's creating a <body> element, not selecting the <body> element in the current document.

dmethvin avatar Jun 12 '17 01:06 dmethvin

Thank you for the response. I actually wanted to emphasize the part from the Types page.

If Selector is specified as the type of an argument, it accepts everything that the jQuery constructor accepts, eg. Strings, Elements, Lists of Elements.

After looking over a decent portion of the documentation, it seems that Selector will never refer to Elements or Lists of Elements. I believe that that part of the Types page is incorrect.

leonard-thieu avatar Jun 12 '17 20:06 leonard-thieu

Can you suggest some wording that would clarify it?

dmethvin avatar Jun 12 '17 21:06 dmethvin

Removing that specific paragraph would be good. The rest of the text describes Selector well and is consistent with how Selector is used throughout the rest of the documentation.

leonard-thieu avatar Jun 12 '17 21:06 leonard-thieu

Yep, I agree.

dmethvin avatar Jun 12 '17 22:06 dmethvin

Hey @leonard-thieu did you mean to close this? We should leave the ticket open until the change is made.

dmethvin avatar Jun 19 '17 14:06 dmethvin