Skip to content
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

Standardize custom pseudo object #2073

Closed
gibson042 opened this issue Feb 7, 2015 · 4 comments
Closed

Standardize custom pseudo object #2073

gibson042 opened this issue Feb 7, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@gibson042
Copy link
Member

cc @timmywil @scottgonzalez

The Sizzle pseudos object is exposed on jQuery.expr as three distinct properties:

  • jQuery.expr.pseudos
  • jQuery.expr.filters
  • jQuery.expr[":"]

Sizzle defines the first two, and jQuery defines the third.

None of them appear in the current jQuery documentation, though Sizzle documents the object as pseudos (and separately documents the related setFilters), and I'm sure we have published instructions on how to define a custom pseudo at least once, which would necessarily reference one of them. We also have internal uses in at least two libraries:

  • core
    • defines jQuery.expr[":"] from jQuery.expr.pseudos
    • defines :hidden, :visible, and :animated by extending jQuery.expr.filters
    • calls jQuery.expr.filters.hidden in the :visible pseudo
  • UI
    • defines :data, :focusable, :tabbable, and widget pseudos by extending $.expr[ ":" ]
    • replaces the :animated filter at $.expr.filters.animated
    • calls $.expr.filters.visible and $.expr.filters.hidden

So now that this issue affects three source repositories and jquery/api.jquery.com, here's the crux of it: can we standardize on one internally and deprecate the others? All things considered, my vote would be on filters.

@timmywil
Copy link
Member

timmywil commented Feb 8, 2015

I actually would like to keep them all. [":"] is probably the most prevalent in user code and needs to stay regardless. filters has been there a long time, but it wasn't used as much. And pseudos is NWMatchers' name for filters, so it's a more intuitive name to some.

Regardless, I'd like to continue recommending the use of the .createPseudo() method for creating custom selectors, making the choice of one property somewhat moot – except for setFilter. jQuery UI already uses it where available.

@gibson042
Copy link
Member Author

I actually would like to keep them all.

In the sense of not moving to deprecated, or of not standardizing?

[":"] is probably the most prevalent in user code and needs to stay regardless.

But still exceedingly rare from (among other things) its lack of documentation, and with a fix that couldn't be simpler. At any rate, though, I propose deprecation not because I think we can remove them anytime soon, but to promote consistency.

filters has been there a long time, but it wasn't used as much.

That would depend on your measurement criteria... it's probably the most used by execution count from jQuery UI alone. And to the extent that any such special-case functionality can be used "much", I bet updating api.jquery.com would address the educational gap.

And pseudos is NWMatchers' name for filters, so it's a more intuitive name to some.

Then it appears NWMatcher has moved on, at least from an API perspective (which is what I'm addressing). However, even if it hadn't, maintaining surface area in jQuery core to support transitioning from an independent selector engine seems... overaccommodating.

Regardless, I'd like to continue recommending the use of the .createPseudo() method for creating custom selectors, making the choice of one property somewhat moot – except for setFilter.

Not at all; the result of createPseudo still has to be assigned to an object property. e.g.: data: $.expr.createPseudo…

@timmywil
Copy link
Member

timmywil commented Feb 8, 2015

That would depend on your measurement criteria... it's probably the most used by execution count from jQuery UI alone. And to the extent that any such special-case functionality can be used "much", I bet updating api.jquery.com would address the educational gap.

I think we're on different wavelengths here. In terms of defining custom pseudos, you said jQuery UI mostly used [":"] and only used .filters once. Still, I was referring to user code in general and I just remember seeing [":"] much more often. Maybe my memory is off.

Not at all; the result of createPseudo still has to be assigned to an object property. e.g.: data: $.expr.createPseudo…

Totally true. Brain fart. However, the main point there was createPseudo isn't in jQuery's documentation either.

I'm all for documenting custom pseudo creation in jQuery (and I'm fine picking a property and sticking with it), but I still don't see the value behind deprecating the other properties. To me, deprecation voices the intention of removal whether we say it does or not. If we use the same property in all of our documentation, that seems like enough.

@timmywil
Copy link
Member

timmywil commented Feb 1, 2016

Per meeting, decided on "pseudos".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants