I recently had a quick look at the new jQuery Sizzle, i was wondering if there is any significant performance difference between using Sizzle.matchesSelector or assessing directly the attribute of the element parameter :
$.expr.createPseudo(function(selector) {
return function( elem ) {
return elem.getAttribute('data-smth').match(/someRegex/)
}
}
VS :
$.expr.createPseudo(function(selector) {
return function( elem ) {
return $.find.matchesSelector(elem, 'div.someClass[data-smth*=smth]')
}
}
I find personaly matchesSelector easier since we keep on jquery level and we can add easily some constraints (.someClass in my exemple above)