3

In the jQuery source it clearly says jQuery.find = Sizzle;

but when i try to access a particular Sizzle method the function doesn't exist. This is what the objects look like.

window.Sizzle   |   window.jQuery.find

.isXML          |   .isXML
.matches        |   .matches
.matchesSelector|   .matchesSelector
.contains       |   .contains
.attr           |   .attr
.error          |   .error
.uniqueSort     |   .uniqueSort
.getText        |   .getText
.selectors      |   .selectors
.tokenize       |   
.compile        |   
.select         |   
.support        |   
.setDocument    |   
                |   .find
                |   .filter 

I don't understand why the jquery team would overwrite/delete the methods. Is there a way of accessing these missing functions or do I have to download the sizzle library ? The method I need it tokenize.

jquery source
Sizzlejs source

Many Thanks

TarranJones
  • 4,084
  • 2
  • 38
  • 55
  • If `window.Sizzle`, doesn't that mean the library is already downloaded? – Anthony Feb 20 '15 at 11:47
  • May be you should take a look at the migrate plugin as suggested by jquery team. – Jai Feb 20 '15 at 11:48
  • @Anthony Sorry yea, I loaded it just for comparison. Sizzle is only available to the jquery object because its in a closure so it is not globally accessible. – TarranJones Feb 20 '15 at 12:06
  • @Jai This is not a version issue. when I said it was removed I mean it exists in the sizzle object but not in the $.find object. I did not mean that the methods once existed in a previous version of jQuery and deprecated – TarranJones Feb 20 '15 at 12:07

2 Answers2

1

AFAIK you can use $.find.tokenize - see issue https://github.com/jquery/sizzle/issues/242

Joe Fitter
  • 1,309
  • 7
  • 11
  • 1
    $.find.tokenize does exist in newer version of jquery – TarranJones Feb 20 '15 at 12:20
  • Thanks, I had seen that issue but i assumed it was a problem with jquery as when i was using sizzle the methods were accessible. I was using a version of jquery that used the older verion of the sizzle library before that commit. – TarranJones Feb 20 '15 at 12:25
0

For those who want to access Sizzle methods from jQuery for whatever reason...

In jQuery source we have...

jQuery.find = Sizzle;

So all Sizzle methods can be accessed from jQuery.find

shramee
  • 5,030
  • 1
  • 22
  • 46