-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(jqLite): use querySelectorAll instead of getElementsByTagName in jqLite.find #3598
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
is there a queryselectorall polyfill? I found https://gist.github.com/branneman/1200441 qsa is supported on IE8+ so that's good I'm happy to merge this in after 1.2 |
The gist is just using the plain old Sizzle, just like jQuery does. Do we want to include Sizzle somehow or should we leave this up to the app to handle? On Thursday, August 15, 2013 at 10:33 AM, Igor Minar wrote:
|
👍 Thanks for implementing. |
Sizzle may be too large (minified@18k) for AngularJS. |
18k seems expensive, given that the only browsers that don't support it is IE 6 and 7. And that problem is solved by calling |
If jqLite continues to grow, at one point it might be better to replace it with custom jQuery 2.x build. You can even exclude Sizzle there! jQuery handles lots of cross-browser problems so that would be a plus. I'd be monitoring the situation about when it would be a good moment to switch (as jqLite grows and jQuery gets more & more componentized, we e.g. switched internally to AMD recently). I am a jQuery Core team member, though, so I might be a little biased. :) |
The conditional will cause silent errors for IE<8 if the selector is not a tag name. It's better to only use querySelectorAll so that users on IE<8 get an error, rather than not see an error, but don't get the expected result either. I'd rather have conditional code blocks for IE<8 if they work as expected, even though we don't official support it, rather than conditional code blocks that may or may not work everytime. Or alternatively, explicitly state that the function only accepts tag names and not full CSS queries. In that case, the function would run faster if it used getElementsByTagName over querySelectorAll under certain scenarios and would be the same in the rest of the scenarios. |
Instead of Sizzle perhaps look at https://github.com/ded/qwery as a querySelectorAll polyfill? I only just came across it (don't know anything about it), however it looks much slimmer than the polyfill linked to above. |
@mzgol - I am pretty sure that at some point we will do exactly that. The question is as you say when the optimal moment arrives. |
👍 would love to get this in ng |
If we get this in 1.2 this way we'll have this problem #4120. Don't forget to verify if there's no text nodes. |
👍 |
1 similar comment
👍 |
@mzgol we tried building a custom jquery2 build but it was still huge. |
@mzgol quite frankly, I'd love to throw jqLite away if we could get a jQuery build of comparable size and functionality. |
@IgorMinar In the meantime, why not just merge this pull request? It makes "find" significantly more useful. |
+1 |
7 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
This is a great addition, but I'm a little concerned about the unintuitive scoping behavior of querySelectorAll. This would be easy to patch for browsers that support the |
+1 |
2 similar comments
+1 |
+1 |
02dc2aa
to
fd2d6c0
Compare
fixing this properly is non trivial and won't happen in 1.3. moving this back to backlog. |
8292c21
to
7b9fddf
Compare
4dd5a20
to
998c61c
Compare
+1 |
Any plans on merging this in time for 1.4 or 2.0? |
@ilanbiala --- the main reason we don't is because we wouldn't be able to provide the expected results (although we could provide very similar results to jquery 2.x). There are polyfills available for some of the missing features, (like https://github.com/termi/CSS_selector_engine), so it's probably possible for us to do it. Leave that up to @petebacondarwin though |
@caitp thanks for the update. |
If we were to use an external CSS selector engine, we might as well use the BTW, Sizzle will be dropping support for browsers not supported by jQuery I feel that escapes jqLite's goal, though - if we want to be more |
Correction: since only gzipped sizes matter; here they are: Sizzle: 6.9 KB And note that the next Sizzle version will be smaller. |
+1 |
1 similar comment
+1 |
+1 |
I think it's time for this one to be closed. we can take another attempt at this in the future (with the next level of DOM), but I don't think there's much hope for the aspirations of this right now. |
Addresses #3586