Changeset 5985
- Timestamp:
- 12/21/08 21:22:44 (7 months ago)
- Location:
- trunk/jquery
- Files:
-
- 6 modified
-
build.xml (modified) (1 diff)
-
Makefile (modified) (1 diff)
-
src/ajax.js (modified) (2 diffs)
-
src/core.js (modified) (17 diffs)
-
src/dimensions.js (modified) (1 diff)
-
src/event.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jquery/build.xml
r5345 r5985 36 36 <fileset dir="${SRC_DIR}" includes="intro.js" /> 37 37 <fileset dir="${SRC_DIR}" includes="core.js" /> 38 <fileset dir="${SRC_DIR}" includes="support.js" /> 38 39 <fileset dir="${SRC_DIR}" includes="selector.js" /> 39 40 <fileset dir="${SRC_DIR}" includes="event.js" /> -
trunk/jquery/Makefile
r5345 r5985 10 10 11 11 BASE_FILES = ${SRC_DIR}/core.js\ 12 ${SRC_DIR}/support.js\ 12 13 ${SRC_DIR}/selector.js\ 13 14 ${SRC_DIR}/event.js\ -
trunk/jquery/src/ajax.js
r5948 r5985 460 460 // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 461 461 return !xhr.status && location.protocol == "file:" || 462 ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 || 463 jQuery.browser.safari && xhr.status === undefined; 462 ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; 464 463 } catch(e){} 465 464 return false; … … 472 471 473 472 // Firefox always returns 200. check Last-Modified date 474 return xhr.status == 304 || xhrRes == jQuery.lastModified[url] || 475 jQuery.browser.safari && xhr.status === undefined; 473 return xhr.status == 304 || xhrRes == jQuery.lastModified[url]; 476 474 } catch(e){} 477 475 return false; -
trunk/jquery/src/core.js
r5984 r5985 286 286 // Do the clone 287 287 var ret = this.map(function(){ 288 if ( jQuery.browser.msie&& !jQuery.isXMLDoc(this) ) {288 if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { 289 289 // IE copies events bound via attachEvent when 290 290 // using cloneNode. Calling detachEvent on the … … 643 643 644 644 script.type = "text/javascript"; 645 if ( jQuery.browser.msie ) 645 if ( jQuery.support.scriptEval ) 646 script.appendChild( document.createTextNode( data ) ); 647 else 646 648 script.text = data; 647 else648 script.appendChild( document.createTextNode( data ) );649 649 650 650 // Use insertBefore instead of appendChild to circumvent an IE6 bug. … … 835 835 var ret, style = elem.style; 836 836 837 // A helper method for determining if an element's values are broken838 function color( elem ) {839 if ( !jQuery.browser.safari )840 return false;841 842 // defaultView is cached843 var ret = defaultView.getComputedStyle( elem, null );844 return !ret || ret.getPropertyValue("color") == "";845 }846 847 837 // We need to handle opacity special in IE 848 if ( name == "opacity" && jQuery.browser.msie) {838 if ( name == "opacity" && !jQuery.support.opacity ) { 849 839 ret = jQuery.attr( style, "opacity" ); 850 840 … … 853 843 ret; 854 844 } 855 // Opera sometimes will give the wrong display answer, this fixes it, see #2037856 if ( jQuery.browser.opera && name == "display" ) {857 var save = style.outline;858 style.outline = "0 solid black";859 style.outline = save;860 }861 845 862 846 // Make sure we're using the right name for getting the float value … … 877 861 var computedStyle = defaultView.getComputedStyle( elem, null ); 878 862 879 if ( computedStyle && !color( elem ))863 if ( computedStyle ) 880 864 ret = computedStyle.getPropertyValue( name ); 881 882 // If the element isn't reporting its values properly in Safari883 // then some display: none elements are involved884 else {885 var swap = [], stack = [], a = elem, i = 0;886 887 // Locate all of the parent display: none elements888 for ( ; a && color(a); a = a.parentNode )889 stack.unshift(a);890 891 // Go through and make them visible, but in reverse892 // (It would be better if we knew the exact display type that they had)893 for ( ; i < stack.length; i++ )894 if ( color( stack[ i ] ) ) {895 swap[ i ] = stack[ i ].style.display;896 stack[ i ].style.display = "block";897 }898 899 // Since we flip the display style, we have to handle that900 // one special, otherwise get the value901 ret = name == "display" && swap[ stack.length - 1 ] != null ?902 "none" :903 ( computedStyle && computedStyle.getPropertyValue( name ) ) || "";904 905 // Finally, revert the display styles back906 for ( i = 0; i < swap.length; i++ )907 if ( swap[ i ] != null )908 stack[ i ].style.display = swap[ i ];909 }910 865 911 866 // We should always get a number back from opacity … … 992 947 993 948 // IE can't serialize <link> and <script> tags normally 994 jQuery.browser.msie &&949 !jQuery.support.htmlSerialize && 995 950 [ 1, "div<div>", "</div>" ] || 996 951 … … 1005 960 1006 961 // Remove IE's autoinserted <tbody> from table fragments 1007 if ( jQuery.browser.msie) {962 if ( !jQuery.support.tbody ) { 1008 963 1009 964 // String was a <table>, *may* have spurious <tbody> … … 1020 975 tbody[ j ].parentNode.removeChild( tbody[ j ] ); 1021 976 1022 // IE completely kills leading whitespace when innerHTML is used1023 if ( /^\s/.test( elem ) ) 1024 div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );1025 1026 }977 } 978 979 // IE completely kills leading whitespace when innerHTML is used 980 if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) ) 981 div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); 1027 982 1028 983 if ( fragment ) { … … 1069 1024 var notxml = !jQuery.isXMLDoc( elem ), 1070 1025 // Whether we are setting (or getting) 1071 set = value !== undefined, 1072 msie = jQuery.browser.msie; 1026 set = value !== undefined; 1073 1027 1074 1028 // Try to normalize/fix the name … … 1084 1038 // Safari mis-reports the default selected property of a hidden option 1085 1039 // Accessing the parent's selectedIndex property fixes it 1086 if ( name == "selected" && jQuery.browser.safari)1040 if ( name == "selected" ) 1087 1041 elem.parentNode.selectedIndex; 1088 1042 … … 1104 1058 } 1105 1059 1106 if ( msie && notxml && name == "style" )1060 if ( !jQuery.support.style && notxml && name == "style" ) 1107 1061 return jQuery.attr( elem.style, "cssText", value ); 1108 1062 … … 1111 1065 elem.setAttribute( name, "" + value ); 1112 1066 1113 var attr = msie&& notxml && special1067 var attr = !jQuery.support.hrefNormalized && notxml && special 1114 1068 // Some attributes require a special call on IE 1115 1069 ? elem.getAttribute( name, 2 ) … … 1123 1077 1124 1078 // IE uses filters for opacity 1125 if ( msie&& name == "opacity" ) {1079 if ( !jQuery.support.opacity && name == "opacity" ) { 1126 1080 if ( set ) { 1127 1081 // IE has trouble with opacity if it does not have layout … … 1184 1138 // Also, we need to make sure that the correct elements are being returned 1185 1139 // (IE returns comment nodes in a '*' query) 1186 if ( jQuery.browser.msie) {1140 if ( !jQuery.support.getAll ) { 1187 1141 while ( (elem = second[ i++ ]) ) 1188 1142 if ( elem.nodeType != 8 ) … … 1244 1198 } 1245 1199 }); 1200 1201 // Use of jQuery.browser is deprecated. 1202 // It's included for backwards compatibility and plugins, 1203 // although they should work to migrate away. 1246 1204 1247 1205 var userAgent = navigator.userAgent.toLowerCase(); … … 1256 1214 }; 1257 1215 1258 var styleFloat = jQuery.browser.msie ? 1259 "styleFloat" : 1260 "cssFloat"; 1261 1262 jQuery.extend({ 1263 // Check to see if the W3C box model is being used 1264 boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat", 1265 1266 props: { 1267 "for": "htmlFor", 1268 "class": "className", 1269 "float": styleFloat, 1270 cssFloat: styleFloat, 1271 styleFloat: styleFloat, 1272 readonly: "readOnly", 1273 maxlength: "maxLength", 1274 cellspacing: "cellSpacing", 1275 rowspan: "rowSpan" 1276 } 1277 }); 1216 // Check to see if the W3C box model is being used 1217 jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat"; 1278 1218 1279 1219 jQuery.each({ … … 1360 1300 }); 1361 1301 1362 jQuery.each([ "Height", "Width" ], function(i, name){1363 var type = name.toLowerCase();1364 1365 jQuery.fn[ type ] = function( size ) {1366 // Get window width or height1367 return this[0] == window ?1368 // Opera reports document.body.client[Width/Height] properly in both quirks and standards1369 jQuery.browser.opera && document.body.parentNode[ "client" + name ] ||1370 1371 // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)1372 jQuery.browser.safari && window[ "inner" + name ] ||1373 1374 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode1375 document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :1376 1377 // Get document width or height1378 this[0] == document ?1379 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater1380 Math.max(1381 Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),1382 Math.max(document.body["offset" + name], document.documentElement["offset" + name])1383 ) :1384 1385 // Get or set width or height on the element1386 size === undefined ?1387 // Get width or height on the element1388 (this.length ? jQuery.css( this[0], type ) : null) :1389 1390 // Set the width or height on the element (default to pixels if value is unitless)1391 this.css( type, typeof size === "string" ? size : size + "px" );1392 };1393 });1394 1395 1302 // Helper function used by the dimensions and offset modules 1396 1303 function num(elem, prop) { -
trunk/jquery/src/dimensions.js
r5603 r5985 20 20 num(this, "margin" + tl) + num(this, "margin" + br) : 0); 21 21 }; 22 23 var type = name.toLowerCase(); 24 25 jQuery.fn[ type ] = function( size ) { 26 // Get window width or height 27 return this[0] == window ? 28 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode 29 document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || 30 document.body[ "client" + name ] : 31 32 // Get document width or height 33 this[0] == document ? 34 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater 35 Math.max( 36 document.documentElement["client" + name], 37 document.body["scroll" + name], document.documentElement["scroll" + name], 38 document.body["offset" + name], document.documentElement["offset" + name] 39 ) : 40 41 // Get or set width or height on the element 42 size === undefined ? 43 // Get width or height on the element 44 (this.length ? jQuery.css( this[0], type ) : null) : 45 46 // Set the width or height on the element (default to pixels if value is unitless) 47 this.css( type, typeof size === "string" ? size : size + "px" ); 48 }; 22 49 23 50 }); -
trunk/jquery/src/event.js
r5978 r5985 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)16 if ( elem.setInterval && elem != window ) 17 17 elem = window; 18 18 … … 384 384 } 385 385 386 if ( !jQuery.browser.msie ){ 387 // Checks if an event happened on an element within another element 388 // Used in jQuery.event.special.mouseenter and mouseleave handlers 389 var withinElement = function(event) { 390 // Check if mouse(over|out) are still within the same parent element 391 var parent = event.relatedTarget; 392 // Traverse up the tree 393 while ( parent && parent != this ) 394 try { parent = parent.parentNode; } 395 catch(e) { parent = this; } 396 397 if( parent != this ){ 398 // set the correct event type 399 event.type = event.data; 400 // handle event if we actually just moused on to a non sub-element 401 jQuery.event.handle.apply( this, arguments ); 402 } 403 }; 386 // Checks if an event happened on an element within another element 387 // Used in jQuery.event.special.mouseenter and mouseleave handlers 388 var withinElement = function(event) { 389 // Check if mouse(over|out) are still within the same parent element 390 var parent = event.relatedTarget; 391 // Traverse up the tree 392 while ( parent && parent != this ) 393 try { parent = parent.parentNode; } 394 catch(e) { parent = this; } 404 395 405 jQuery.each({ 406 mouseover: 'mouseenter', 407 mouseout: 'mouseleave' 408 }, function( orig, fix ){ 409 jQuery.event.special[ fix ] = { 410 setup: function(){ 411 jQuery.event.add( this, orig, withinElement, fix ); 412 }, 413 teardown: function(){ 414 jQuery.event.remove( this, orig, withinElement ); 415 } 416 }; 417 }); 418 } 396 if( parent != this ){ 397 // set the correct event type 398 event.type = event.data; 399 // handle event if we actually just moused on to a non sub-element 400 jQuery.event.handle.apply( this, arguments ); 401 } 402 }; 403 404 jQuery.each({ 405 mouseover: 'mouseenter', 406 mouseout: 'mouseleave' 407 }, function( orig, fix ){ 408 jQuery.event.special[ fix ] = { 409 setup: function(){ 410 jQuery.event.add( this, orig, withinElement, fix ); 411 }, 412 teardown: function(){ 413 jQuery.event.remove( this, orig, withinElement ); 414 } 415 }; 416 }); 419 417 420 418 jQuery.fn.extend({
