X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=8c27b42b137e024beda0f7f55de054e365163f35;hb=e1e631a04440c0d9ab6580ea1593286072fa7ef5;hp=ddcddce0640804f912a9344572b4058a9545f306;hpb=c6e6e72561979ab80aaf5ce1ab63d3dd010382a3;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index ddcddce..8c27b42 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -33,7 +33,7 @@ var jQuery = function(a,c) { // HANDLE: $(function) // Shortcut for document ready // Safari reports typeof on DOM NodeLists as a function - if ( typeof a == "function" && !a.nodeType && a[0] == undefined ) + if ( jQuery.isFunction(a) && !a.nodeType && a[0] == undefined ) return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a ); // Handle HTML strings @@ -548,7 +548,7 @@ jQuery.fn = jQuery.prototype = { "textContent" : "innerText"; return e == undefined ? - this.length && this[0][ type ] : + jQuery.map(this, function(a){ return a[ type ]; }).join("") : this.each(function(){ this[ type ] = e; }); }, @@ -813,6 +813,7 @@ jQuery.fn = jQuery.prototype = { * * @name clone * @type jQuery + * @param Boolean deep (Optional) Set to false if you don't want to clone all descendant nodes, in addition to the element itself. * @cat DOM/Manipulation */ clone: function(deep) { @@ -863,7 +864,7 @@ jQuery.fn = jQuery.prototype = { */ filter: function(t) { return this.pushStack( - t.constructor == Function && + jQuery.isFunction( t ) && jQuery.grep(this, function(el, index){ return t.apply(el, [index]) }) || @@ -924,7 +925,7 @@ jQuery.fn = jQuery.prototype = { jQuery.grep(this,function(a){ if ( t.constructor == Array || t.jquery ) - return !jQuery.inArray( t, a ); + return jQuery.inArray( t, a ) < 0; else return a != t; }) ); @@ -1211,6 +1212,10 @@ jQuery.extend({ $ = jQuery._$; }, + isFunction: function( fn ) { + return fn && typeof fn == "function"; + }, + /** * A generic iterator function, which can be used to seemlessly * iterate over both objects and arrays. This function is not the same @@ -1252,8 +1257,8 @@ jQuery.extend({ prop: function(elem, value, type){ // Handle executable functions - if ( value.constructor == Function ) - return value.call( elem ) + if ( jQuery.isFunction( value ) ) + return value.call( elem ); // Handle passing in a number to a CSS property if ( value.constructor == Number && type == "css" ) @@ -1276,7 +1281,7 @@ jQuery.extend({ elem.className = c ? jQuery.grep( elem.className.split(/\s+/), function(cur){ return !jQuery.className.has( c, cur ); - }).join(' ') : ""; + }).join(" ") : ""; }, // internal only, use is(".class") @@ -1343,8 +1348,8 @@ jQuery.extend({ curCSS: function(elem, prop, force) { var ret; - if (prop == 'opacity' && jQuery.browser.msie) - return jQuery.attr(elem.style, 'opacity'); + if (prop == "opacity" && jQuery.browser.msie) + return jQuery.attr(elem.style, "opacity"); if (prop == "float" || prop == "cssFloat") prop = jQuery.browser.msie ? "styleFloat" : "cssFloat"; @@ -1362,12 +1367,12 @@ jQuery.extend({ if ( cur ) ret = cur.getPropertyValue(prop); - else if ( prop == 'display' ) - ret = 'none'; + else if ( prop == "display" ) + ret = "none"; else - jQuery.swap(elem, { display: 'block' }, function() { - var c = document.defaultView.getComputedStyle(this, ''); - ret = c && c.getPropertyValue(prop) || ''; + jQuery.swap(elem, { display: "block" }, function() { + var c = document.defaultView.getComputedStyle(this, ""); + ret = c && c.getPropertyValue(prop) || ""; }); } else if (elem.currentStyle) { @@ -1382,9 +1387,14 @@ jQuery.extend({ clean: function(a) { var r = []; - + for ( var i = 0, al = a.length; i < al; i++ ) { var arg = a[i]; + + if ( !arg ) continue; + + if ( arg.constructor == Number ) + arg = arg.toString(); // Convert html string into DOM nodes if ( typeof arg == "string" ) { @@ -1435,7 +1445,7 @@ jQuery.extend({ arg = div.childNodes; } - if ( arg.nodeType ) + if ( arg[0] == undefined ) r.push( arg ); else r = jQuery.merge( r, arg ); @@ -1483,7 +1493,7 @@ jQuery.extend({ if ( value != undefined ) elem[fix[name]] = value; return elem[fix[name]]; - } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) + } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == "FORM" && (name == "action" || name == "method") ) return elem.getAttributeNode(name).nodeValue; // IE elem.getAttribute passes even for style @@ -1698,7 +1708,7 @@ jQuery.extend({ */ /* - * Wheather the W3C compliant box model is being used. + * Whether the W3C compliant box model is being used. * * @property * @name $.boxModel