]> source.dussan.org Git - jquery.git/commitdiff
Bug #7608 elem.runtimeStyle throws exception in Opera 162/head
authorrwldrn <waldron.rick@gmail.com>
Wed, 5 Jan 2011 18:32:59 +0000 (13:32 -0500)
committerrwldrn <waldron.rick@gmail.com>
Wed, 5 Jan 2011 18:32:59 +0000 (13:32 -0500)
src/css.js
test/unit/css.js

index 8a83c6072bd409b0dc65c7f17ff3cebf1afa9f7b..19c6342d22b853fd087becaec4b373bbb5b16eaa 100644 (file)
@@ -263,8 +263,9 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
 
 if ( document.documentElement.currentStyle ) {
        currentStyle = function( elem, name ) {
-               var left, rsLeft,
+               var left, 
                        ret = elem.currentStyle && elem.currentStyle[ name ],
+                       rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
                        style = elem.style;
 
                // From the awesome hack by Dean Edwards
@@ -275,16 +276,19 @@ if ( document.documentElement.currentStyle ) {
                if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
                        // Remember the original values
                        left = style.left;
-                       rsLeft = elem.runtimeStyle.left;
 
                        // Put in the new values to get a computed value out
-                       elem.runtimeStyle.left = elem.currentStyle.left;
+                       if ( rsLeft ) {
+                               elem.runtimeStyle.left = elem.currentStyle.left;
+                       }
                        style.left = name === "fontSize" ? "1em" : (ret || 0);
                        ret = style.pixelLeft + "px";
 
                        // Revert the changed values
                        style.left = left;
-                       elem.runtimeStyle.left = rsLeft;
+                       if ( rsLeft ) {
+                               elem.runtimeStyle.left = rsLeft;
+                       }
                }
 
                return ret === "" ? "auto" : ret;
index fbbf937ca6e2b54ec5927c073f001b49876f0668..edc340cebe6cd3417ede780aa8150d8ec63b0c09 100644 (file)
@@ -320,3 +320,25 @@ test(":visible selector works properly on children with a hidden parent (bug #45
        jQuery('#table').css('display', 'none').html('<tr><td>cell</td><td>cell</td></tr>');
        equals(jQuery('#table td:visible').length, 0, "hidden cell children not perceived as visible");
 });
+
+test("internal ref to elem.runtimeStyle (bug #7608)", function () {
+  expect(1);
+  
+  var result = true, 
+      val = 10;
+
+  jQuery('<div id="bug7608" style="width:200px;border:solid 1px red;">' +
+    '<div  id="test" style="width:0%; background:#000;">&nbsp;</div></div>').appendTo("body");
+    
+  try {
+       // the bug is located within src/css.js
+    jQuery("#bug7608 #test").animate( { width: val }, 1000);    
+    
+  } catch (e) {
+    result = false;  
+  }
+  
+  ok( result, "elem.runtimeStyle does not throw exception" );
+  
+  jQuery("#bug7608").remove();
+});