My first try wasn't exactly right. Here goes again:

match: function() {
  var expressions = $A(arguments), element = $(expressions.shift());
  expressions = expressions.join(',').split(',')
  return !Object.isUndefined(expressions.detect(function(selector) {
    selector = new Selector(selector);
    return selector.match($(element));
  }));
},

On Nov 8, 1:15 pm, metavida <[EMAIL PROTECTED]> wrote:
> The Element#match function doesn't work correctly with a CSS selector
> that includes comma separated values. This means that Element#select
> and Element#match behave differently when passed the same CSS
> selector. The following is an example of how match should work.
> $$('input, label').collect(function(e) {return e.match('input,
> label')}) //=> an Array with all true values
>
> Instead the following currently happens:
> $$('input, label').collect(function(e) {return e.match('input,
> label')}) //=> false is returned for each label
>
> The following is a replacement for the current match method (based on
> Element#select) but haven't had a chance to turn it into a patch or
> properly test it. Anyone want to lend a hand? :-)
>
> match: function(element, selector) {
>     var expressions = $A(arguments), element = $(expressions.shift());
>     var exprs = expressions.join(','), expressions = [];
>     exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m)
> {
>       expressions.push(m[1].strip());
>     });
>     return !Object.isUndefined(expressions.detect(function(selector) {
>       selector = new Selector(selector);
>       return selector.match($(element));
>     }));
>   },


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to