Forced the test suite into standards mode. Fixed some issues with how opacity was...
[jquery.git] / src / jquery / jquery.js
index 12ec613..0c00829 100644 (file)
@@ -774,30 +774,10 @@ jQuery.fn = jQuery.prototype = {
         * If there was no destructive operation before, an empty set is returned.
         *
         * A 'destructive' operation is any operation that changes the set of
-        * matched jQuery elements. These functions are:
-        * These functions are: 
-        *
-        * <code>add</code>
-        *
-        * <code>children</code>
-        *
-        * <code>clone</code>
-        *
-        * <code>filter</code>
-        *
-        * <code>find</code>
-        *
-        * <code>not</code>
-        *
-        * <code>next</code>
-        *
-        * <code>parent</code>
-        *
-        * <code>parents</code>
-        *
-        * <code>prev</code>
-        *
-        * <code>siblings</code>
+        * matched jQuery elements. These functions are: <code>add</code>,
+        * <code>children</code>, <code>clone</code>, <code>filter</code>,
+        * <code>find</code>, <code>not</code>, <code>next</code>,
+        * <code>parent</code>, <code>parents</code>, <code>prev</code> and <code>siblings</code>.
         *
         * @example $("p").find("span").end();
         * @before <p><span>Hello</span>, how are you?</p>
@@ -952,10 +932,6 @@ jQuery.fn = jQuery.prototype = {
         * Please note: the expression cannot use a reference to the
         * element name. See the two examples below.
         *
-        * This will not work: $(".res img").not("img[@src$=on]")
-        *
-        * This will: $(".res img").not("[@src$=on]"); // also could be written $(".res img:not([@src$=on])")
-        *
         * @example $("p").not( $("div p.selected") )
         * @before <div><p>Hello</p><p class="selected">Hello Again</p></div>
         * @result [ <p>Hello</p> ]
@@ -1279,7 +1255,7 @@ jQuery.extend({
        // is the only cross-browser way to do this. --John
        isFunction: function( fn ) {
                return !!fn && typeof fn != "string" && !fn.nodeName && 
-                       typeof fn[0] == "undefined" && /function/i.test( fn + "" );
+                       fn.constructor != Array && /function/i.test( fn + "" );
        },
        
        // check if an element is in a XML document
@@ -1426,12 +1402,12 @@ jQuery.extend({
 
        curCSS: function(elem, prop, force) {
                var ret;
-               
+
                if (prop == "opacity" && jQuery.browser.msie)
                        return jQuery.attr(elem.style, "opacity");
-                       
+               
                if (prop == "float" || prop == "cssFloat")
-                   prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
+                       prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
 
                if (!force && elem.style[prop])
                        ret = elem.style[prop];
@@ -1455,10 +1431,8 @@ jQuery.extend({
                                });
 
                } else if (elem.currentStyle) {
-
                        var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
                        ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
-                       
                }
 
                return ret;
@@ -1496,7 +1470,7 @@ jQuery.extend({
                                        [0,"",""];
 
                                // Go to html and back, then peel off extra wrappers
-                               div.innerHTML = wrap[1] + s + wrap[2];
+                               div.innerHTML = wrap[1] + arg + wrap[2];
                                
                                // Move to the right depth
                                while ( wrap[0]-- )
@@ -1519,7 +1493,7 @@ jQuery.extend({
                                        
                                }
                                
-                               arg = div.childNodes;
+                               arg = jQuery.makeArray( div.childNodes );
                        }
 
                        if ( arg.length === 0 && !jQuery.nodeName(arg, "form") )
@@ -1551,24 +1525,21 @@ jQuery.extend({
                };
                
                // IE actually uses filters for opacity ... elem is actually elem.style
-               if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
-                       // IE has trouble with opacity if it does not have layout
-                       // Force it by setting the zoom level
-                       elem.zoom = 1; 
-
-                       // Set the alpha filter to set the opacity
-                       return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
-                               ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
+               if ( name == "opacity" && jQuery.browser.msie ) {
+                       if ( value != undefined ) {
+                               // IE has trouble with opacity if it does not have layout
+                               // Force it by setting the zoom level
+                               elem.zoom = 1; 
+
+                               // Set the alpha filter to set the opacity
+                               elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") +
+                                       (parseFloat(value).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
+                       }
 
-               } else if ( name == "opacity" && jQuery.browser.msie )
                        return elem.filter ? 
-                               parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
+                               (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";
+               }
                
-               // Mozilla doesn't play well with opacity 1
-               if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
-                       value = 0.9999;
-                       
-
                // Certain attributes only work when accessed via the old DOM 0 way
                if ( fix[name] ) {
                        if ( value != undefined ) elem[fix[name]] = value;
@@ -1610,7 +1581,8 @@ jQuery.extend({
        makeArray: function( a ) {
                var r = [];
 
-               if ( a.constructor != Array )
+               // Need to use typeof to fight Safari childNodes crashes
+               if ( typeof a != "array" )
                        for ( var i = 0, al = a.length; i < al; i++ )
                                r.push( a[i] );
                else