aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-01-10 18:06:19 +0000
committerJohn Resig <jeresig@gmail.com>2007-01-10 18:06:19 +0000
commit75b6bcdb4206fc8cb0bd4294bdc9fef87c44325d (patch)
tree92568366b53d2bc226740cd1a6bb6d1297521265
parentf2ff0db0320cfab0d856ff68d012cb843c97b600 (diff)
downloadjquery-75b6bcdb4206fc8cb0bd4294bdc9fef87c44325d.tar.gz
jquery-75b6bcdb4206fc8cb0bd4294bdc9fef87c44325d.zip
Added support .css("left",30). Fixed up the multiFilter code.
-rw-r--r--src/jquery/jquery.js24
-rw-r--r--src/selector/selector.js9
2 files changed, 20 insertions, 13 deletions
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index cc0af5212..46019bf94 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -432,7 +432,7 @@ jQuery.fn = jQuery.prototype = {
for ( var prop in obj )
jQuery.attr(
type ? this.style : this,
- prop, jQuery.prop(this, obj[prop])
+ prop, jQuery.prop(this, obj[prop], type)
);
});
},
@@ -477,16 +477,22 @@ jQuery.fn = jQuery.prototype = {
/**
* Set a single style property to a value, on all matched elements.
+ * If a number is provided, it is automatically converted into a pixel value.
*
* @example $("p").css("color","red");
* @before <p>Test Paragraph.</p>
* @result <p style="color:red;">Test Paragraph.</p>
* @desc Changes the color of all paragraphs to red
*
+ * @example $("p").css("left",30);
+ * @before <p>Test Paragraph.</p>
+ * @result <p style="left:30px;">Test Paragraph.</p>
+ * @desc Changes the left of all paragraphs to "30px"
+ *
* @name css
* @type jQuery
* @param String key The name of the property to set.
- * @param Object value The value to set the property to.
+ * @param String|Number value The value to set the property to.
* @cat CSS
*/
css: function( key, value ) {
@@ -1236,10 +1242,16 @@ jQuery.extend({
return obj;
},
- prop: function(elem, value){
- // Handle executable functions
- return value.constructor == Function &&
- value.call( elem ) || value;
+ prop: function(elem, value, type){
+ // Handle executable functions
+ if ( value.constructor == Function )
+ return value.call( elem )
+
+ // Handle passing in a number to a CSS property
+ if ( value.constructor == Number && type == "css" )
+ return value + "px";
+
+ return value;
},
className: {
diff --git a/src/selector/selector.js b/src/selector/selector.js
index 1bad21b63..40ac53dfa 100644
--- a/src/selector/selector.js
+++ b/src/selector/selector.js
@@ -93,16 +93,11 @@ jQuery.extend({
var old, cur = [];
while ( expr && expr != old ) {
-console.log( cur, expr, elems, not );
+ old = expr;
var f = jQuery.filter( expr, elems, not );
expr = f.t.replace(/^\s*,\s*/, "" );
-
- if ( not )
- cur = elems = f.r;
- else
- cur = jQuery.merge( cur, f.r );
+ cur = not ? elems = f.r : jQuery.merge( cur, f.r );
}
-console.log( "DONE", cur, expr, elems, not );
return cur;
},