Your tests don't check that the selector actually matched anything. No great surprise that querySelectorAll
won when it knew there weren't any data-role
tags and so could immediately return an empty NodeList
. :-)
And indeed, if you add checks to each test to make sure it really got the right number of elements, the querySelectorAll
one fails: http://jsperf.com/jqmdata-vs-attribute-selecotr/5