Permalink
Browse files

add non-standard selectors, prototype binding

  • Loading branch information...
1 parent bb9240d commit a4aa817e776e4cfde39c0c9976f6d4e8e3c269ff @chjj committed Mar 8, 2012
Showing with 21 additions and 3 deletions.
  1. +2 −0 ext/zest.prototype.js
  2. +19 −3 lib/zest.js
View
@@ -13,6 +13,8 @@
//= require "zest"
;(function(engine) {
+ engine.noNative();
+
var extendElements = Prototype.Selector.extendElements;
function select(selector, scope) {
View
@@ -405,7 +405,22 @@ var selectors = {
},
':future': function(el) {
throw new Error(':future is not supported.');
+ },
+ // Non-standard, for compatibility purposes.
+ ':contains': function(param) {
+ return function(el) {
+ var text = el.innerText || el.textContent || el.value || '';
+ return !!~text.indexOf(param);
+ };
+ },
+ ':has': function(param) {
+ return function(el) {
+ return zest(param, el).length > 0;
+ };
}
+ // Potentially add more pseudo selectors for
+ // compatibility with sizzle and most other
+ // selector engines (?).
};
/**
@@ -419,9 +434,6 @@ var operators = {
'=': function(attr, val) {
return attr === val;
},
- '!=': function(attr, val) {
- return attr !== val;
- },
'*=': function(attr, val) {
return attr.indexOf(val) !== -1;
},
@@ -450,6 +462,10 @@ var operators = {
},
'$=': function(attr, val) {
return attr.indexOf(val) + val.length === attr.length;
+ },
+ // non-standard
+ '!=': function(attr, val) {
+ return attr !== val;
}
};

0 comments on commit a4aa817

Please sign in to comment.