]> source.dussan.org Git - jquery.git/commitdiff
replace cssPropsAware branch 316/head
authorlouisremi <louisremi@louisremi-laptop.(none)>
Mon, 11 Apr 2011 18:33:52 +0000 (20:33 +0200)
committerlouisremi <louisremi@louisremi-laptop.(none)>
Mon, 11 Apr 2011 18:33:52 +0000 (20:33 +0200)
src/css.js
test/unit/css.js

index 65ec20f575fab872a9b14fdf457e352b09d52a20..d53a1f63cc7d6e650b549dc230480ac1f7f5d86f 100644 (file)
@@ -123,10 +123,16 @@ jQuery.extend({
 
        css: function( elem, name, extra ) {
                // Make sure that we're working with the right name
-               var ret, origName = jQuery.camelCase( name ),
-                       hooks = jQuery.cssHooks[ origName ];
-
-               name = jQuery.cssProps[ origName ] || origName;
+               var ret,
+                       hooks;
+
+               name = jQuery.camelCase( name );
+               hooks = jQuery.cssHooks[ name ];
+               name = jQuery.cssProps[ name ] || name;
+               // cssFloat needs a special treatment
+               if ( name === 'cssFloat' ) {
+                       name = 'float';
+               }
 
                // If a hook was provided get the computed value from there
                if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
@@ -134,7 +140,7 @@ jQuery.extend({
 
                // Otherwise, if a way to get the computed value exists, use that
                } else if ( curCSS ) {
-                       return curCSS( elem, name, origName );
+                       return curCSS( elem, name );
                }
        },
 
@@ -273,7 +279,7 @@ jQuery(function() {
 });
 
 if ( document.defaultView && document.defaultView.getComputedStyle ) {
-       getComputedStyle = function( elem, newName, name ) {
+       getComputedStyle = function( elem, name ) {
                var ret, defaultView, computedStyle;
 
                name = name.replace( rupper, "-$1" ).toLowerCase();
index 08f50ef2575f6bf9ff4ca3dcfb1b59ec38e5e19d..904312be6dbd794594365914ff33864d51892d32 100644 (file)
@@ -377,3 +377,17 @@ test("marginRight computed style (bug #3333)", function() {
 
        equals($div.css("marginRight"), "0px");
 });
+
+test("jQuery.cssProps behavior, (bug #8402)", function() {
+       var div = jQuery( "<div>" ).appendTo(document.body).css({
+               position: "absolute",
+               top: 0,
+               left: 10
+       });
+       jQuery.cssProps.top = "left";
+       equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style");
+       div.css("top", "100px");
+       equal( div[0].style.left, "100px", "the fixed property is used when setting the style");
+       // cleanup jQuery.cssProps
+       jQuery.cssProps.top = undefined;
+});
\ No newline at end of file