Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

value getters (e.g. readAttribute) now don't mess element collection.…

… add setProperty method
  • Loading branch information...
commit 777ec3cf0a08ec2d141523c68eebad55ada0a6f5 1 parent 9983980
authored May 29, 2008

Showing 1 changed file with 10 additions and 4 deletions. Show diff stats Hide diff stats

  1. 14  protoquery.js
14  protoquery.js
@@ -14,7 +14,6 @@
14 14
 // etc.
15 15
 
16 16
 (function(){
17  
-  var global = (function(){ return this })();
18 17
   
19 18
   var Wrapper = Class.create({
20 19
     initialize: function(selector) {
@@ -33,7 +32,8 @@
33 32
       return function() {
34 33
         var args = $A(arguments);
35 34
         this.elements = this.elements.map(function(element) {
36  
-          return Element.Methods[method].apply(null, [element].concat(args));
  35
+          var result = Element.Methods[method].apply(null, [element].concat(args));
  36
+          return Object.isElement(result) ? result : element;
37 37
         }).compact();
38 38
         return this;
39 39
       }
@@ -45,11 +45,17 @@
45 45
       return Object.inspect(this.elements);
46 46
     },
47 47
     hover: function(over, out) {
48  
-      this.observe('mouseover', function(e) {
  48
+      return this.observe('mouseover', function(e) {
49 49
         over.call(e.target, e);
50 50
       }).observe('mouseout', function(e) {
51 51
         out.call(e.target, e);
52 52
       });
  53
+    },
  54
+    setProperty: function(name, value) {
  55
+      this.each(function(element) {
  56
+        element[name] = value;
  57
+      });
  58
+      return this;
53 59
     }
54 60
   });
55 61
   
@@ -62,7 +68,7 @@
62 68
     })(eventName);
63 69
   });
64 70
   
65  
-  global.$Q = function(selector) {
  71
+  this.$Q = function(selector) {
66 72
     return new Wrapper(selector);
67 73
   };
68 74
 })();

0 notes on commit 777ec3c

Please sign in to comment.
Something went wrong with that request. Please try again.