var splitValueBy = function(delimiter) { return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; }
switch (attribute.operator) { case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break; case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break; case '|=': conditions.push( splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect() ); break; case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break; case '': case undefined: conditions.push(value + ' != null'); break; default: throw 'Unknown operator ' + attribute.operator + ' in selector'; } }); }
return conditions.join(' && '); },
compileMatcher: function() { this.match = new Function('element', 'if (!element.tagName) return false; \ return ' + this.buildMatchExpression()); },
findElements: function(scope) { var element;
if (element = $(this.params.id)) if (this.match(element)) if (!scope || Element.childOf(element, scope)) return [element];
scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
var results = []; for (var i = 0; i < scope.length; i++) if (this.match(element = scope[i])) results.push(Element.extend(element));
return results; },
toString: function() { return this.expression; } }
function $$() { return $A(arguments).map(function(expression) { return expression.strip().split(/\s+/).inject([null], function(results, expr) { |