SC.$ doesn’t support complex selectors

  July 12th, 2010

SC.$ doesn’t support complex selectors for performance reasons. For example, the following queries will return an empty or incorrect result set:

SC.$('.foo .bar:first-child')
SC.$(':empty')
SC.$('foo > bar')

If you don’t need your application to be compatible with IE 7 and Firefox 3.0, you can use the querySelectorAll method to overcome that limitation:

MyApp.$ = function(str) {
  return SC.$(document.querySelectorAll(str));
}

Leave a comment