Skip to content
This repository
Browse code

add non-standard selectors, prototype binding

  • Loading branch information...
commit a4aa817e776e4cfde39c0c9976f6d4e8e3c269ff 1 parent bb9240d
Christopher Jeffrey authored March 08, 2012
2  ext/zest.prototype.js
@@ -13,6 +13,8 @@
13 13
 //= require "zest"
14 14
 
15 15
 ;(function(engine) {
  16
+  engine.noNative();
  17
+
16 18
   var extendElements = Prototype.Selector.extendElements;
17 19
 
18 20
   function select(selector, scope) {
22  lib/zest.js
@@ -405,7 +405,22 @@ var selectors = {
405 405
   },
406 406
   ':future': function(el) {
407 407
     throw new Error(':future is not supported.');
  408
+  },
  409
+  // Non-standard, for compatibility purposes.
  410
+  ':contains': function(param) {
  411
+    return function(el) {
  412
+      var text = el.innerText || el.textContent || el.value || '';
  413
+      return !!~text.indexOf(param);
  414
+    };
  415
+  },
  416
+  ':has': function(param) {
  417
+    return function(el) {
  418
+      return zest(param, el).length > 0;
  419
+    };
408 420
   }
  421
+  // Potentially add more pseudo selectors for
  422
+  // compatibility with sizzle and most other
  423
+  // selector engines (?).
409 424
 };
410 425
 
411 426
 /**
@@ -419,9 +434,6 @@ var operators = {
419 434
   '=': function(attr, val) {
420 435
     return attr === val;
421 436
   },
422  
-  '!=': function(attr, val) {
423  
-    return attr !== val;
424  
-  },
425 437
   '*=': function(attr, val) {
426 438
     return attr.indexOf(val) !== -1;
427 439
   },
@@ -450,6 +462,10 @@ var operators = {
450 462
   },
451 463
   '$=': function(attr, val) {
452 464
     return attr.indexOf(val) + val.length === attr.length;
  465
+  },
  466
+  // non-standard
  467
+  '!=': function(attr, val) {
  468
+    return attr !== val;
453 469
   }
454 470
 };
455 471
 

0 notes on commit a4aa817

Please sign in to comment.
Something went wrong with that request. Please try again.