Jörn Zaefferer schrieb:
> Klaus Hartl schrieb:
>> Stupid me, I forgot a return statement (too much Ruby lately)... and 
>> also the unit seems to be required:
>>
>> $('div.image p').css('width', function() {
>>      return $(this).prev().width() + 'px';
>> });
>>   
> jQuery.prop could be modified to append the "px" to computed values like 
> in the above example. This should do it:
> 
> Index: I:/dev/workspace/jquery/src/jquery/jquery.js
> ===================================================================
> --- I:/dev/workspace/jquery/src/jquery/jquery.js      (revision 1327)
> +++ I:/dev/workspace/jquery/src/jquery/jquery.js      (working copy)
> @@ -1280,7 +1280,7 @@
>       prop: function(elem, value, type, index, prop){
>                       // Handle executable functions
>                       if ( jQuery.isFunction( value ) )
> -                             return value.call( elem, [index] );
> +                             value = value.call( elem, [index] );
>                               
>                       // exclude the following css properties to add px
>                       var exclude = 
> /z-?index|font-?weight|opacity|zoom|line-?height/i;
> 
>                       // Handle passing in a number to a CSS property
>                       return value && value.constructor == Number && type == 
> "curCSS" && !exclude.test(prop) ?
>                               value + "px" :
>                               value;
>       },
> 
> Is there anyway where that could break?
> 

I actually thought jQuery was already doing this, that's why I was 
surprised. But now I think I confused that with the dimensions plugin.

Sounds reasonable to me.



-- Klaus

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to