<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -6,91 +6,99 @@
  *  A class that queries the document for elements that match a given CSS
  *  selector.
 **/
-var Selector = Class.create({
-  /**
-   *  new Selector(expression)
-   *  - expression (String): A CSS selector.
-   *
-   *  Creates a `Selector` with the given CSS selector.
-  **/
-  initialize: function(expression) {
-    this.expression = expression.strip();
-  },
+(function() {
+  function extend(elements) {
+    for (var i = 0, length = elements.length; i &lt; length; i++)
+      elements[i] = Element.extend(elements[i]);
+    return elements;
+  }
+
+  window.Selector = Class.create({
+    /**
+     *  new Selector(expression)
+     *  - expression (String): A CSS selector.
+     *
+     *  Creates a `Selector` with the given CSS selector.
+    **/
+    initialize: function(expression) {
+      this.expression = expression.strip();
+    },
   
-  /**
-   *  Selector#findElements(root) -&gt; [Element...]
-   *  - root (Element || document): A &quot;scope&quot; to search within. All results will
-   *    be descendants of this node.
-   *
-   *  Searches the document for elements that match the instance's CSS
-   *  selector.
-  **/
-  findElements: function(rootElement) {
-    return Sizzle(this.expression, rootElement || document);
-  },
+    /**
+     *  Selector#findElements(root) -&gt; [Element...]
+     *  - root (Element || document): A &quot;scope&quot; to search within. All results will
+     *    be descendants of this node.
+     *
+     *  Searches the document for elements that match the instance's CSS
+     *  selector.
+    **/
+    findElements: function(rootElement) {
+      return extend(Sizzle(this.expression, rootElement || document));
+    },
   
-  /**
-   *  Selector#match(element) -&gt; Boolean
-   *
-   *  Tests whether a `element` matches the instance's CSS selector.
-  **/
-  match: function(element) {
-    return Sizzle.matches(this.expression, [element]).length == 1;
-  },
+    /**
+     *  Selector#match(element) -&gt; Boolean
+     *
+     *  Tests whether a `element` matches the instance's CSS selector.
+    **/
+    match: function(element) {
+      return Sizzle.matches(this.expression, [element]).length == 1;
+    },
   
-  toString: function() {
-    return this.expression;
-  },
+    toString: function() {
+      return this.expression;
+    },
   
-  inspect: function() {
-    return &quot;#&lt;Selector: &quot; + this.expression + &quot;&gt;&quot;;
-  }
-});
+    inspect: function() {
+      return &quot;#&lt;Selector: &quot; + this.expression + &quot;&gt;&quot;;
+    }
+  });
 
-Object.extend(Selector, {
-  /**
-   *  Selector.matchElements(elements, expression) -&gt; [Element...]
-   *
-   *  Filters the given collection of elements with `expression`.
-   *
-   *  The only nodes returned will be those that match the given CSS selector.
-  **/
-  matchElements: function(elements, expression) {
-    return Sizzle.matches(expression, elements);
-  },
-  
-  /**
-   *  Selector.findElement(elements, expression[, index = 0]) -&gt; Element
-   *  Selector.findElement(elements[, index = 0]) -&gt; Element
-   *
-   *  Returns the `index`th element in the collection that matches
-   *  `expression`.
-   *
-   *  Returns the `index`th element overall if `expression` is not given.
-  **/
-  findElement: function(elements, expression, index) {
-    if (Object.isUndefined(index)) index = 0;
-    return Sizzle.matches(expression, elements)[index];
-  },
-  
-  /**
-   *  Selector.findChildElements(element, expressions) -&gt; [Element...]
+  Object.extend(Selector, {
+    /**
+     *  Selector.matchElements(elements, expression) -&gt; [Element...]
+     *
+     *  Filters the given collection of elements with `expression`.
+     *
+     *  The only nodes returned will be those that match the given CSS selector.
+    **/
+    matchElements: function(elements, expression) {
+      return extend(Sizzle.matches(expression, elements));
+    },
+
+    /**
+     *  Selector.findElement(elements, expression[, index = 0]) -&gt; Element
+     *  Selector.findElement(elements[, index = 0]) -&gt; Element
+     *
+     *  Returns the `index`th element in the collection that matches
+     *  `expression`.
+     *
+     *  Returns the `index`th element overall if `expression` is not given.
+    **/
+    findElement: function(elements, expression, index) {
+      if (Object.isUndefined(index)) index = 0;
+      return Element.extend(Sizzle.matches(expression, elements)[index]);
+    },
+
+    /**
+     *  Selector.findChildElements(element, expressions) -&gt; [Element...]
+     *
+     *  Searches beneath `element` for any elements that match the selector
+     *  (or selectors) specified in `expressions`.
+    **/
+    findChildElements: function(element, expressions) {
+      var results = [], exprs = expressions.toArray();
+      while (exprs.length) Sizzle(exprs.shift(), element || document, results);
+      return extend(results);
+    }
+  });
+
+  /** related to: Selector
+   *  $$(expression...) -&gt; [Element...]
    *
-   *  Searches beneath `element` for any elements that match the selector
-   *  (or selectors) specified in `expressions`.
+   *  Returns all elements in the document that match the provided CSS selectors.
   **/
-  findChildElements: function(element, expressions) {
-    var results = [], exprs = expressions.toArray();
-    while (exprs.length) Sizzle(exprs.shift(), element || document, results);
-    return results;
+  window.$$ = function() {
+    return Selector.findChildElements(document, $A(arguments));
   }
-});
-
-/** related to: Selector
- *  $$(expression...) -&gt; [Element...]
- *
- *  Returns all elements in the document that match the provided CSS selectors.
-**/
-function $$() {
-  return Selector.findChildElements(document, $A(arguments)).map(Element.extend);
-}
+})();</diff>
      <filename>src/dom/selector.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4dd878f237e79db11a6532e3f74059c9b908069c</id>
    </parent>
  </parents>
  <author>
    <name>Sam Stephenson</name>
    <login>sstephenson</login>
    <email>sam@37signals.com</email>
  </author>
  <url>http://github.com/sstephenson/prototype/commit/79cf30aab1ae1016c6e2666b30435bb7c118418a</url>
  <id>79cf30aab1ae1016c6e2666b30435bb7c118418a</id>
  <committed-date>2009-09-19T14:17:43-07:00</committed-date>
  <authored-date>2009-09-19T14:17:43-07:00</authored-date>
  <message>Extend matched elements</message>
  <tree>331d647a2cb5e4ab886a331d2127e8ad90c447b0</tree>
  <committer>
    <name>Sam Stephenson</name>
    <login>sstephenson</login>
    <email>sam@37signals.com</email>
  </committer>
</commit>
