Skip to content

Commit

Permalink
Added Element.match. Element.prototype.match seems irrelevant, but I …
Browse files Browse the repository at this point in the history
…left it just the same.
  • Loading branch information
mattmccray committed Dec 8, 2008
1 parent 05d548a commit ee365ef
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions selectors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
return (parsed) ? Selectors.Utils.filter(this, parsed, {}) : true;
};
// Element.match
Element.match = function(el, selector){
if (!selector) return true;
selector = selector.toString();
var tagid = Selectors.Utils.parseTagAndID(selector);
var tag = tagid[0], id = tagid[1];
if (!Selectors.Filters.byID(el, id) || !Selectors.Filters.byTag(el, tag)) return false;
var parsed = Selectors.Utils.parseSelector(selector);
return (parsed) ? Selectors.Utils.filter(el, parsed, {}) : true;
};
// Provides polymorphic access to getElementById to Elements as well as documents, both of which
// can be passed into Selectors.Utils.search as location for searching for subelements.
Element.prototype.getElementById = function(id, nocash){
Expand Down

1 comment on commit ee365ef

@trek
Copy link

@trek trek commented on ee365ef Jan 15, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey matt,
you may want to check out the sizzle-enabled version of redshift. It obviates the need for this patch (because it no longer users the moo css selector library)

http://github.com/backtik/redshift/tree/sizzle

Please sign in to comment.