Ticket #2743: potpourri.diff
| File potpourri.diff, 22.5 kB (added by flesler, 3 months ago) |
|---|
-
ajax.js
20 20 if ( jQuery.isFunction( params ) ) { 21 21 // We assume that it's the callback 22 22 callback = params; 23 params = null;23 params = undefined; 24 24 25 25 // Otherwise, build a param string 26 26 } else { … … 74 74 }) 75 75 .map(function(i, elem){ 76 76 var val = jQuery(this).val(); 77 return val == null ? null:77 return val == undefined ? undefined : 78 78 val.constructor == Array ? 79 79 jQuery.map( val, function(val, i){ 80 80 return {name: elem.name, value: val}; … … 98 98 // shift arguments if data argument was ommited 99 99 if ( jQuery.isFunction( data ) ) { 100 100 callback = data; 101 data = null;101 data = undefined; 102 102 } 103 103 104 104 return jQuery.ajax({ … … 111 111 }, 112 112 113 113 getScript: function( url, callback ) { 114 return jQuery.get(url, null, callback, "script");114 return jQuery.get(url, undefined, callback, "script"); 115 115 }, 116 116 117 117 getJSON: function( url, data, callback ) { … … 144 144 contentType: "application/x-www-form-urlencoded", 145 145 processData: true, 146 146 async: true, 147 data: null,148 username: null,149 password: null,147 data: undefined, 148 username: undefined, 149 password: undefined, 150 150 accepts: { 151 151 xml: "application/xml, text/xml", 152 152 html: "text/html", … … 207 207 }; 208 208 } 209 209 210 if ( s.dataType == "script" && s.cache == null)210 if ( s.dataType == "script" && s.cache == undefined ) 211 211 s.cache = false; 212 212 213 213 if ( s.cache === false && s.type.toLowerCase() == "get" ) { … … 223 223 s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; 224 224 225 225 // IE likes to send both get and post data, prevent this 226 s.data = null;226 s.data = undefined; 227 227 } 228 228 229 229 // Watch for a new set of requests … … 311 311 // clear poll interval 312 312 if (ival) { 313 313 clearInterval(ival); 314 ival = null;314 ival = undefined; 315 315 } 316 316 317 317 status = isTimeout == "timeout" && "timeout" || … … 351 351 352 352 // Stop memory leaks 353 353 if ( s.async ) 354 xml = null;354 xml = undefined; 355 355 } 356 356 }; 357 357 … … 377 377 try { 378 378 xml.send(s.data); 379 379 } catch(e) { 380 jQuery.handleError(s, xml, null, e);380 jQuery.handleError(s, xml, undefined, e); 381 381 } 382 382 383 383 // firefox 1.5 doesn't fire statechange for sync requests … … 448 448 }, 449 449 450 450 httpData: function( r, type ) { 451 var ct = r.getResponseHeader("content-type") ;452 var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;453 vardata = xml ? r.responseXML : r.responseText;451 var ct = r.getResponseHeader("content-type"), 452 xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, 453 data = xml ? r.responseXML : r.responseText; 454 454 455 455 if ( xml && data.documentElement.tagName == "parsererror" ) 456 456 throw "parsererror"; -
core.js
10 10 */ 11 11 12 12 // Map over jQuery in case of overwrite 13 if ( window.jQuery ) 14 var _jQuery = window.jQuery; 13 var _jQuery = this.jQuery, 15 14 16 var jQuery = window.jQuery = function( selector, context ) {17 // The jQuery object is actually just the init constructor 'enhanced'18 return new jQuery.prototype.init( selector, context );19 };20 21 15 // Map over the $ in case of overwrite 22 if ( window.$ ) 23 var _$ = window.$; 16 _$ = this.$, 24 17 25 // Map the jQuery namespace to the '$' one 26 window.$ = jQuery; 18 //- when munging variables, every undefined turns into one-letter name. 19 //- faster lookups: http://snurl.com/25pcd 20 undefined; 27 21 22 var jQuery = this.jQuery = this.$ = function( selector, context ) { 23 // The jQuery object is actually just the init constructor 'enhanced' 24 return new jQuery.fn.init( selector, context ); 25 }; 26 28 27 // A simple way to check for HTML strings or ID strings 29 28 // (both of which we optimize for) 30 var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/ ;29 var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/, 31 30 32 31 // Is it a simple selector 33 varisSimple = /^.[^:#\[\.]*$/;32 isSimple = /^.[^:#\[\.]*$/; 34 33 35 34 jQuery.fn = jQuery.prototype = { 36 35 init: function( selector, context ) { … … 148 147 // Determine the position of an element within 149 148 // the matched set of elements 150 149 index: function( elem ) { 151 var ret = -1; 152 153 // Locate the position of the desired element 154 this.each(function(i){ 155 if ( this == elem ) 156 ret = i; 157 }); 158 159 return ret; 150 return jQuery.inArray( elem, this ); 160 151 }, 161 152 162 153 attr: function( name, value, type ) { … … 193 184 }, 194 185 195 186 text: function( text ) { 196 if ( typeof text != "object" && text != null)187 if ( typeof text != "object" && text != undefined ) 197 188 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); 198 189 199 190 var ret = ""; … … 306 297 // this is primarily for IE but the data expando shouldn't be copied over in any browser 307 298 var clone = ret.find("*").andSelf().each(function(){ 308 299 if ( this[ expando ] != undefined ) 309 this[ expando ] = null;300 this[ expando ] = undefined; 310 301 }); 311 302 312 303 // Copy the events from the original to the clone … … 359 350 }, 360 351 361 352 is: function( selector ) { 362 return selector ? 363 jQuery.multiFilter( selector, this ).length > 0 : 364 false; 353 return !!selector && jQuery.multiFilter( selector, this ).length > 0 ; 365 354 }, 366 355 367 356 hasClass: function( selector ) { … … 383 372 384 373 // Nothing was selected 385 374 if ( index < 0 ) 386 return null;375 return undefined; 387 376 388 377 // Loop through all the selected options 389 378 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { … … 410 399 411 400 } 412 401 413 return undefined;402 return; 414 403 } 415 404 416 405 return this.each(function(){ … … 443 432 return value == undefined ? 444 433 (this.length ? 445 434 this[0].innerHTML : 446 null) :435 undefined) : 447 436 this.empty().append( value ); 448 437 }, 449 438 … … 473 462 var parts = key.split("."); 474 463 parts[1] = parts[1] ? "." + parts[1] : ""; 475 464 476 if ( value == null) {465 if ( value == undefined ) { 477 466 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); 478 467 479 468 if ( data == undefined && this.length ) 480 469 data = jQuery.data( this[0], key ); 481 470 482 return data == null&& parts[1] ?471 return data == undefined && parts[1] ? 483 472 this.data( parts[0] ) : 484 473 data; 485 474 } else … … 536 525 }; 537 526 538 527 // Give the init function the jQuery prototype for later instantiation 539 jQuery. prototype.init.prototype = jQuery.prototype;528 jQuery.fn.init.prototype = jQuery.fn; 540 529 541 530 function evalScript( i, elem ) { 542 531 if ( elem.src ) … … 570 559 target = {}; 571 560 572 561 // extend jQuery itself if only one argument is passed 573 if ( length == 1) {562 if ( length - i == 0 ) { 574 563 target = this; 575 564 i = 0; 576 565 } 577 566 578 567 for ( ; i < length; i++ ) 579 568 // Only deal with non-null/undefined values 580 if ( (options = arguments[ i ]) != null)569 if ( (options = arguments[ i ]) != undefined ) 581 570 // Extend the base object 582 for ( var name in options ) { 571 for ( var name in options ) { 572 var src = target[name], copy = options[name]; 573 583 574 // Prevent never-ending loop 584 if ( target === options[ name ])575 if ( target === copy ) 585 576 continue; 586 577 587 578 // Recurse if we're merging object values 588 if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )589 target[ name ] = jQuery.extend( deep, target[ name ], options[ name ]);579 if ( deep && copy && typeof copy == "object" && src && !copy.nodeType ) 580 target[ name ] = jQuery.extend( deep, src, copy ); 590 581 591 582 // Don't bring in undefined values 592 else if ( options[ name ]!= undefined )593 target[ name ] = options[ name ];583 else if ( copy != undefined ) 584 target[ name ] = copy; 594 585 595 586 } 596 587 … … 598 589 return target; 599 590 }; 600 591 601 var expando = "jQuery" + ( new Date()).getTime(), uuid = 0, windowData = {};592 var expando = "jQuery" + (+new Date), uuid = 0, windowData = {}, 602 593 603 594 // exclude the following css properties to add px 604 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; 595 exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, 605 596 // cache getComputedStyle 606 vargetComputedStyle = document.defaultView && document.defaultView.getComputedStyle;597 getComputedStyle = document.defaultView && document.defaultView.getComputedStyle; 607 598 608 599 jQuery.extend({ 609 600 noConflict: function( deep ) { … … 800 791 801 792 css: function( elem, name, force ) { 802 793 if ( name == "width" || name == "height" ) { 803 var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; 794 var val, props = { position: "absolute", visibility: "hidden", display:"block" }, 795 which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; 804 796 805 797 function getWH() { 806 798 val = name == "width" ? elem.offsetWidth : elem.offsetHeight; … … 874 866 // If the element isn't reporting its values properly in Safari 875 867 // then some display: none elements are involved 876 868 else { 877 var swap = [], stack = [] ;869 var swap = [], stack = [], a, i; 878 870 879 871 // Locate all of the parent display: none elements 880 for ( vara = elem; a && color(a); a = a.parentNode )872 for ( a = elem; a && color(a); a = a.parentNode ) 881 873 stack.unshift(a); 882 874 883 875 // Go through and make them visible, but in reverse 884 876 // (It would be better if we knew the exact display type that they had) 885 for ( vari = 0; i < stack.length; i++ )877 for ( i = 0; i < stack.length; i++ ) 886 878 if ( color( stack[ i ] ) ) { 887 879 swap[ i ] = stack[ i ].style.display; 888 880 stack[ i ].style.display = "block"; … … 890 882 891 883 // Since we flip the display style, we have to handle that 892 884 // one special, otherwise get the value 893 ret = name == "display" && swap[ stack.length - 1 ] != null?885 ret = name == "display" && swap[ stack.length - 1 ] != undefined ? 894 886 "none" : 895 887 ( computedStyle && computedStyle.getPropertyValue( name ) ) || ""; 896 888 897 889 // Finally, revert the display styles back 898 for ( vari = 0; i < swap.length; i++ )899 if ( swap[ i ] != null)890 for ( i = 0; i < swap.length; i++ ) 891 if ( swap[ i ] != undefined ) 900 892 stack[ i ].style.display = swap[ i ]; 901 893 } 902 894 … … 946 938 return; 947 939 948 940 if ( elem.constructor == Number ) 949 elem = elem.toString();941 elem += ''; 950 942 951 943 // Convert html string into DOM nodes 952 944 if ( typeof elem == "string" ) { … … 958 950 }); 959 951 960 952 // Trim whitespace, otherwise indexOf won't work as expected 961 var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div"); 953 var tags = jQuery.trim( elem ).toLowerCase(), 954 div = context.createElement("div"); 962 955 963 956 var wrap = 964 957 // option or optgroup … … 1353 1346 // Get or set width or height on the element 1354 1347 size == undefined ? 1355 1348 // Get width or height on the element 1356 (this.length ? jQuery.css( this[0], type ) : null) :1349 (this.length ? jQuery.css( this[0], type ) : undefined) : 1357 1350 1358 1351 // Set the width or height on the element (default to pixels if value is unitless) 1359 1352 this.css( type, size.constructor == String ? size : size + "px" ); -
event.js
13 13 14 14 // For whatever reason, IE has trouble passing the window object 15 15 // around, causing it to be cloned in the process 16 if ( jQuery.browser.msie && elem.setInterval != undefined)16 if ( jQuery.browser.msie && elem.setInterval ) 17 17 elem = window; 18 18 19 19 // Make sure that the function being executed has a unique ID … … 51 51 // event in IE. 52 52 handle.elem = elem; 53 53 54 // Handle multiple events seperated by a space55 // jQuery(...).bind("mouseover mouseout", fn);56 jQuery.each(types.split(/\s+/), function(index, type) {57 // Namespaced event handlers58 var parts = type.split(".");59 type = parts[0];60 handler.type = parts[1];54 // Handle multiple events separated by a space 55 // jQuery(...).bind("mouseover mouseout", fn); 56 jQuery.each(types.split(/\s+/), function(index, type) { 57 // Namespaced event handlers 58 var parts = type.split("."); 59 type = parts[0]; 60 handler.type = parts[1]; 61 61 62 // Get the current list of functions bound to this event63 var handlers = events[type];62 // Get the current list of functions bound to this event 63 var handlers = events[type]; 64 64 65 // Init the event handler queue 66 if (!handlers) { 67 handlers = events[type] = {}; 68 69 // Check for a special event handler 70 // Only use addEventListener/attachEvent if the special 71 // events handler returns false 72 if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) { 73 // Bind the global event handler to the element 74 if (elem.addEventListener) 75 elem.addEventListener(type, handle, false); 76 else if (elem.attachEvent) 77 elem.attachEvent("on" + type, handle); 78 } 65 // Init the event handler queue 66 if (!handlers) { 67 handlers = events[type] = {}; 68 69 // Check for a special event handler 70 // Only use addEventListener/attachEvent if the special 71 // events handler returns false 72 if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) { 73 // Bind the global event handler to the element 74 if (elem.addEventListener) 75 elem.addEventListener(type, handle, false); 76 else if (elem.attachEvent) 77 elem.attachEvent("on" + type, handle); 79 78 } 79 } 80 80 81 // Add the function to the element's handler list82 handlers[handler.guid] = handler;81 // Add the function to the element's handler list 82 handlers[handler.guid] = handler; 83 83 84 // Keep track of which events have been used, for global triggering85 jQuery.event.global[type] = true;86 });84 // Keep track of which events have been used, for global triggering 85 jQuery.event.global[type] = true; 86 }); 87 87 88 88 // Nullify elem to prevent memory leaks in IE 89 elem = null;89 elem = undefined; 90 90 }, 91 91 92 92 guid: 1, … … 140 140 else if (elem.detachEvent) 141 141 elem.detachEvent("on" + type, jQuery.data(elem, "handle")); 142 142 } 143 ret = null;143 ret = undefined; 144 144 delete events[type]; 145 145 } 146 146 } … … 151 151 for ( ret in events ) break; 152 152 if ( !ret ) { 153 153 var handle = jQuery.data( elem, "handle" ); 154 if ( handle ) handle.elem = null;154 if ( handle ) handle.elem = undefined; 155 155 jQuery.removeData( elem, "events" ); 156 156 jQuery.removeData( elem, "handle" ); 157 157 } … … 179 179 if ( elem.nodeType == 3 || elem.nodeType == 8 ) 180 180 return undefined; 181 181 182 var val, ret, fn = jQuery.isFunction( elem[ type ] || null),182 var val, ret, fn = jQuery.isFunction( elem[ type ] || undefined ), 183 183 // Check to see if we need to provide a fake event, or not 184 184 event = !data[0] || !data[0].preventDefault; 185 185 … … 208 208 // Handle triggering of extra function 209 209 if ( extra && jQuery.isFunction( extra ) ) { 210 210 // call the extra function and tack the current return value on the end for possible inspection 211 ret = extra.apply( elem, val == null? data : data.concat( val ) );211 ret = extra.apply( elem, val == undefined ? data : data.concat( val ) ); 212 212 // if anything is returned, give it precedence and have it overwrite the previous value 213 213 if (ret !== undefined) 214 214 val = ret; … … 268 268 // Clean up added properties in IE to prevent memory leak 269 269 if (jQuery.browser.msie) 270 270 event.target = event.preventDefault = event.stopPropagation = 271 event.handler = event.data = null;271 event.handler = event.data = undefined; 272 272 273 273 return val; 274 274 }, … … 297 297 }; 298 298 299 299 // Fix timeStamp 300 event.timeStamp = event.timeStamp || +new Date;300 event.timeStamp = event.timeStamp || now(); 301 301 302 302 // Fix target property, if necessary 303 303 if ( !event.target ) … … 312 312 event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; 313 313 314 314 // Calculate pageX/Y if missing and clientX/Y available 315 if ( event.pageX == null && event.clientX != null) {315 if ( event.pageX == undefined && event.clientX != undefined ) { 316 316 var doc = document.documentElement, body = document.body; 317 317 event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); 318 318 event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); … … 362 362 // If we actually just moused on to a sub-element, ignore it 363 363 if ( withinElement(event, this) ) return true; 364 364 // Execute the right handlers by setting the event type to mouseenter 365 arguments[0].type = "mouseenter";365 event.type = "mouseenter"; 366 366 return jQuery.event.handle.apply(this, arguments); 367 367 } 368 368 }, … … 384 384 // If we actually just moused on to a sub-element, ignore it 385 385 if ( withinElement(event, this) ) return true; 386 386 // Execute the right handlers by setting the event type to mouseleave 387 arguments[0].type = "mouseleave";387 event.type = "mouseleave"; 388 388 return jQuery.event.handle.apply(this, arguments); 389 389 } 390 390 } … … 420 420 }, 421 421 422 422 triggerHandler: function( type, data, fn ) { 423 if ( this[0] ) 424 return jQuery.event.trigger( type, data, this[0], false, fn ); 425 return undefined; 423 return this[0] && jQuery.event.trigger( type, data, this[0], false, fn ); 426 424 }, 427 425 428 426 toggle: function() { … … 481 479 }); 482 480 483 481 // Reset the list of functions 484 jQuery.readyList = null;482 jQuery.readyList = undefined; 485 483 } 486 484 487 485 // Trigger any bound ready events -
fx.js
76 76 if ( this.nodeType != 1) 77 77 return false; 78 78 79 var opt = jQuery.extend({}, optall); 80 var hidden = jQuery(this).is(":hidden"), self = this; 79 var opt = jQuery.extend({}, optall), 80 hidden = jQuery(this).is(":hidden"), 81 self = this; 81 82 82 83 for ( var p in prop ) { 83 84 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) … … 92 93 } 93 94 } 94 95 95 if ( opt.overflow != null)96 if ( opt.overflow != undefined ) 96 97 this.style.overflow = "hidden"; 97 98 98 99 opt.curAnim = jQuery.extend({}, prop); … … 180 181 }); 181 182 182 183 var queue = function( elem, type, array ) { 183 if ( !elem ) 184 return undefined; 185 186 type = type || "fx"; 187 188 var q = jQuery.data( elem, type + "queue" ); 189 190 if ( !q || array ) 191 q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) ); 192 184 if ( elem ){ 185 &nbs