chjj / zest

An absurdly fast CSS selector engine.
MIT License
238 stars 14 forks source link

Selecting `:not(.foo)` fails #6

Closed fgnass closed 12 years ago

fgnass commented 12 years ago

... with the following error:

TypeError: Property '1' of object function () {
    return true;
  },,function (el) {
      var attr;
      switch (key) {
        case 'for':
          attr = el.htmlFor;
          break;
        case 'class':
          attr = el.className;
          break;
        case 'href':
          attr = el.getAttribute('href', 2);
          break;
        default:
          attr = el[key] != null
               ? el[key]
               : el.getAttribute(key);
          break;
      }
      return attr != null && op(attr + '', val);
    } is not a function
    at file://localhost/Users/flx/js/zest/test/zest.js:316:21
    at file://localhost/Users/flx/js/zest/test/zest.js:294:14
    at file://localhost/Users/flx/js/zest/test/zest.js:378:18
    at file://localhost/Users/flx/js/zest/test/zest.js:417:9
    at file://localhost/Users/flx/js/zest/test/zest.js:493:12
    at file://localhost/Users/flx/js/zest/test/test.js:117:31
    at file://localhost/Users/flx/js/zest/test/test.js:119:5
    at file://localhost/Users/flx/js/zest/test/test.js:146:3

The problem is that the selector gets split at the nested dot. Any idea how to fix that elegantly?

chjj commented 12 years ago

It could be a problem with the tokenizer. I recently completely rewrote it to match selector grammar more closely and make it more foolproof. I have a huge pile of fixes sitting on my disk right now. They need to be tested on IE and Safari before I actually push them to production though. I've procrastinated on it. I'll see if I can get them up today.

chjj commented 12 years ago

This should be fixed with the latest commits.

fgnass commented 12 years ago

Yep, works perfectly now. Thanks a lot!