-
Notifications
You must be signed in to change notification settings - Fork 43
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
Support jQuery selectors #29
Comments
Hi @chocolateboy, thanks for your interest. The plugin only parses the selector to learn about the nature of the selector. This allows some small performance tweaks that are admittedly probably not of huge benefit in most cases, but could be useful in certain circumstances. For example, if the selector does not contain attribute selectors, then the plugin will not ask the
Please note that actual CSS selector parsing is handled by native JavaScript ( If you can identify any practical bugs as a consequence of this approach, please let us know. |
You might notice that
Is equivalent to:
Also note that this plugin does not have a concept of |
Thanks. I haven't spotted any bugs. I suppose my question was more about why jQuery isn't being used to process the selector rather than why it's being manually parsed. Neither |
That's fine. I usually call its as |
I must reiterate, there is no manual parsing of the selector except for extracting meta data about the selector (the The actual scanning of the document uses |
OK, I think there's a misunderstanding, and I guess I'm not making myself clear. It's specifically the jQuery functionality I'm requesting. CSS (i.e. |
Right. I had to use |
Hi @chocolateboy , I quickly implemented this on feature/support-jquery-selectors. The bug I mentioned doesn't seem to be apparent. Please test or suggest changes if you are interested. |
So, I reproduced the bug that originally made it impossible to support jquery selectors. On the |
I'm also switching from onMutate to your library. Regarding the apparent looping when using .find(), you might have to disconnect your observer just before doing .find(), and reconnect it after. At least that's what I had to do in one of my projects to avoid infinitely looping because I was creating a DOM element within my observer callback. |
I think my issue is related to this issue. This used to work with v1.0.0:
but breaks with v1.3.0 ? |
Yes, your issue is related to this ticket. You may want to use https://api.jquery.com/button-selector/ Also, note that the API has changed, so you should use the following:
|
Possibly related jquery/jquery#4332? |
I have something on feature/support-jquery-selectors2 that seems to work with jQuery 3.7.0. However, I will not release this until I have made it backward-compatible. Older versions will hang. |
If anybody would like to test this on |
If this fails testing, our next chance might be jQuery 4.0, which "inlines & simplifies Sizzle." |
This is on hold for now. |
I'm trying to migrate away from another jQuery plugin, which has several bugs, to this, which doesn't have either of those bugs. 👍
But, looking through the code, there appears to a fair bit of code devoted to parsing the selector, which seems fragile. More importantly, nodes are matched with
Element.matches
, which means that jQuery-specific features like:visible
won't work, and jQuery extensions like:not
only partially work.Since it's a jQuery plugin, why not just use
$(node).is(selector)
instead ofElement.matches
+ custom parsing?The text was updated successfully, but these errors were encountered: