From 90d7cc1d8b2ea7ac75f0eacb42439349c9c73278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Mon, 3 Nov 2014 19:53:22 +0100 Subject: [PATCH] Misc: Drop support for older browsers; update support comments That includes IE<8, Opera 12.x, Firefox<29, Safari<6.0 and some hacks for old Blackberry. Fixes gh-1836 Fixes gh-1701 Refs gh-1815 Refs gh-1820 --- README.md | 2 +- src/.jshintrc | 1 - src/ajax.js | 28 +-- src/ajax/parseJSON.js | 44 +--- src/ajax/script.js | 3 +- src/ajax/xhr.js | 8 +- src/attributes/attr.js | 100 +------- src/attributes/prop.js | 21 -- src/attributes/support.js | 17 +- src/attributes/val.js | 26 +-- src/core.js | 4 +- src/core/init.js | 16 +- src/core/ready.js | 34 +-- src/css.js | 15 +- src/css/curCSS.js | 13 +- src/css/hiddenVisibleSelectors.js | 4 +- src/css/support.js | 23 +- src/dimensions.js | 2 +- src/effects.js | 27 +-- src/effects/support.js | 54 ----- src/event.js | 7 +- src/manipulation.js | 84 ++----- src/manipulation/support.js | 23 +- src/offset.js | 6 +- src/support.js | 38 --- test/data/css/cssWidthBeforeDocReady.html | 1 - test/data/dimensions/documentSmall.html | 10 - test/data/support/shrinkWrapBlocks.html | 23 -- test/data/testsuite.css | 12 +- test/unit/ajax.js | 56 +---- test/unit/attributes.js | 7 +- test/unit/css.js | 39 ++-- test/unit/dimensions.js | 4 +- test/unit/effects.js | 151 +++++------- test/unit/event.js | 80 ++----- test/unit/manipulation.js | 3 +- test/unit/offset.js | 53 ++--- test/unit/selector.js | 6 +- test/unit/serialize.js | 6 +- test/unit/support.js | 273 ++-------------------- test/unit/wrap.js | 3 +- 41 files changed, 253 insertions(+), 1074 deletions(-) delete mode 100644 src/effects/support.js delete mode 100644 test/data/support/shrinkWrapBlocks.html diff --git a/README.md b/README.md index 036b8a43c..e7529b631 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ In the spirit of open source software development, jQuery always encourages comm Environments in which to use jQuery -------------------------------------- -- [Browser support](http://jquery.com/browser-support/) differs between the master branch and the compat branch. Specifically, the master branch does not support legacy browsers such as IE6-8. The jQuery team continues to provide support for legacy browsers on the compat branch. Use the latest compat release if support for those browsers is required. See [browser support](http://jquery.com/browser-support/) for more info. +- [Browser support](http://jquery.com/browser-support/) differs between the master branch and the compat branch. Specifically, the master branch does not support legacy browsers such as IE8. The jQuery team continues to provide support for legacy browsers on the compat branch. Use the latest compat release if support for those browsers is required. See [browser support](http://jquery.com/browser-support/) for more info. - To use jQuery in Node, browser extensions, and other non-browser environments, use only master branch releases given the name "jquery" rather than "jquery-compat". The compat branch does not support these environments. diff --git a/src/.jshintrc b/src/.jshintrc index 10541d501..3ffebfd5a 100644 --- a/src/.jshintrc +++ b/src/.jshintrc @@ -13,7 +13,6 @@ "undef": true, "unused": true, - "evil": true, "sub": true, "es3": true, diff --git a/src/ajax.js b/src/ajax.js index d44a76095..d4a0128b4 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -10,10 +10,6 @@ define([ ], function( jQuery, rnotwhite, nonce, rquery ) { var - // Document location - ajaxLocParts, - ajaxLocation, - rhash = /#.*$/, rts = /([?&])_=[^&]*/, rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL @@ -42,23 +38,13 @@ var transports = {}, // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression - allTypes = "*/".concat("*"); + allTypes = "*/".concat( "*" ), -// Support: IE<8 -// #8138, IE may throw an exception when accessing -// a field from window.location if document.domain has been set -try { - ajaxLocation = location.href; -} catch ( e ) { - // Use the href attribute of an A element - // since IE will modify it given document.location - ajaxLocation = document.createElement( "a" ); - ajaxLocation.href = ""; - ajaxLocation = ajaxLocation.href; -} + // Document location + ajaxLocation = location.href, -// Segment location into parts -ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; + // Segment location into parts + ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport function addToPrefiltersOrTransports( structure ) { @@ -79,7 +65,7 @@ function addToPrefiltersOrTransports( structure ) { // For each dataType in the dataTypeExpression while ( (dataType = dataTypes[i++]) ) { // Prepend if requested - if ( dataType.charAt( 0 ) === "+" ) { + if ( dataType[ 0 ] === "+" ) { dataType = dataType.slice( 1 ) || "*"; (structure[ dataType ] = structure[ dataType ] || []).unshift( func ); @@ -509,7 +495,7 @@ jQuery.extend({ jqXHR.error = jqXHR.fail; // Remove hash character (#7531: and string promotion) - // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) + // Add protocol if not provided (prefilters might expect it) // Handle falsy url in the settings object (#10093: consistency with old signature) // We also use the url parameter if available s.url = ( ( url || s.url || ajaxLocation ) + "" ) diff --git a/src/ajax/parseJSON.js b/src/ajax/parseJSON.js index 69b5c837d..3a96d15b9 100644 --- a/src/ajax/parseJSON.js +++ b/src/ajax/parseJSON.js @@ -2,48 +2,10 @@ define([ "../core" ], function( jQuery ) { -var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g; - +// Support: Android 2.3 +// Workaround failure to string-cast null input jQuery.parseJSON = function( data ) { - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - // Support: Android 2.3 - // Workaround failure to string-cast null input - return window.JSON.parse( data + "" ); - } - - var requireNonComma, - depth = null, - str = jQuery.trim( data + "" ); - - // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains - // after removing valid tokens - return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) { - - // Force termination if we see a misplaced comma - if ( requireNonComma && comma ) { - depth = 0; - } - - // Perform no more replacements after returning to outermost depth - if ( depth === 0 ) { - return token; - } - - // Commas must not follow "[", "{", or "," - requireNonComma = open || comma; - - // Determine new depth - // array/object open ("[" or "{"): depth += true - false (increment) - // array/object close ("]" or "}"): depth += false - true (decrement) - // other cases ("," or primitive): depth += true - true (numeric cast) - depth += !close - !open; - - // Remove this token - return ""; - }) ) ? - ( Function( "return " + str ) )() : - jQuery.error( "Invalid JSON: " + data ); + return JSON.parse( data + "" ); }; return jQuery.parseJSON; diff --git a/src/ajax/script.js b/src/ajax/script.js index 416a45ddb..be422adf3 100644 --- a/src/ajax/script.js +++ b/src/ajax/script.js @@ -77,9 +77,8 @@ jQuery.ajaxTransport( "script", function(s) { } }; - // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending // Use native DOM manipulation to avoid our domManip AJAX trickery - head.insertBefore( script, head.firstChild ); + head.appendChild( script ); }, abort: function() { diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index 149c49e5d..ac5bc81d9 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -7,13 +7,13 @@ define([ // Create the request object // (This is still attached to ajaxSettings for backward compatibility) jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? - // Support: IE6+ + // Support: IE8 function() { // XHR cannot access local files, always use ActiveX for that case return !this.isLocal && - // Support: IE7-8 + // Support: IE<9 // oldIE XHR does not support non-RFC2616 methods (#13240) // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9 @@ -167,10 +167,6 @@ if ( xhrSupported ) { if ( !options.async ) { // if we're in sync mode we fire the callback callback(); - } else if ( xhr.readyState === 4 ) { - // (IE6 & IE7) if it's in cache and has been - // retrieved directly we need to fire the callback - setTimeout( callback ); } else { // Add to the list of active xhr callbacks xhr.onreadystatechange = xhrCallbacks[ id ] = callback; diff --git a/src/attributes/attr.js b/src/attributes/attr.js index 4d8abf320..9c962ef2d 100644 --- a/src/attributes/attr.js +++ b/src/attributes/attr.js @@ -7,10 +7,9 @@ define([ "../selector" ], function( jQuery, rnotwhite, access, support ) { -var nodeHook, boolHook, +var boolHook, attrHandle = jQuery.expr.attrHandle, ruseDefault = /^(?:checked|selected)$/i, - getSetAttribute = support.getSetAttribute, getSetInput = support.input; jQuery.fn.extend({ @@ -45,7 +44,7 @@ jQuery.extend({ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { name = name.toLowerCase(); hooks = jQuery.attrHooks[ name ] || - ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); + ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); } if ( value !== undefined ) { @@ -88,7 +87,7 @@ jQuery.extend({ // Boolean attributes get special treatment (#10870) if ( jQuery.expr.match.bool.test( name ) ) { // Set corresponding property to false - if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { + if ( getSetInput || !ruseDefault.test( name ) ) { elem[ propName ] = false; // Support: IE<9 // Also clear defaultChecked/defaultSelected (if appropriate) @@ -96,13 +95,9 @@ jQuery.extend({ elem[ jQuery.camelCase( "default-" + name ) ] = elem[ propName ] = false; } - - // See #9699 for explanation of this approach (setting first, then removal) - } else { - jQuery.attr( elem, name, "" ); } - elem.removeAttribute( getSetAttribute ? name : propName ); + elem.removeAttribute( name ); } } }, @@ -111,7 +106,7 @@ jQuery.extend({ type: { set: function( elem, value ) { if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 + // Setting the type on a radio button after the value resets the value in IE8-9 // Reset value to default in case type is set after value during creation var val = elem.value; elem.setAttribute( "type", value ); @@ -131,12 +126,12 @@ boolHook = { if ( value === false ) { // Remove boolean attributes when set to false jQuery.removeAttr( elem, name ); - } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { - // IE<8 needs the *property* name - elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); + } else if ( getSetInput || !ruseDefault.test( name ) ) { + elem.setAttribute( jQuery.propFix[ name ] || name, name ); - // Use defaultChecked and defaultSelected for oldIE } else { + // Support: IE<9 + // Use defaultChecked and defaultSelected for oldIE elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; } @@ -149,7 +144,7 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) var getter = attrHandle[ name ] || jQuery.find.attr; - attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ? + attrHandle[ name ] = getSetInput || !ruseDefault.test( name ) ? function( elem, name, isXML ) { var ret, handle; if ( !isXML ) { @@ -173,88 +168,17 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) }); // fix oldIE attroperties -if ( !getSetInput || !getSetAttribute ) { +if ( !getSetInput ) { jQuery.attrHooks.value = { - set: function( elem, value, name ) { + set: function( elem, value ) { if ( jQuery.nodeName( elem, "input" ) ) { // Does not return so that setAttribute is also used elem.defaultValue = value; - } else { - // Use nodeHook if defined (#1954); otherwise setAttribute is fine - return nodeHook && nodeHook.set( elem, value, name ); } } }; } -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = { - set: function( elem, value, name ) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode( name ); - if ( !ret ) { - elem.setAttributeNode( - (ret = elem.ownerDocument.createAttribute( name )) - ); - } - - ret.value = value += ""; - - // Break association with cloned elements by also using setAttribute (#9646) - if ( name === "value" || value === elem.getAttribute( name ) ) { - return value; - } - } - }; - - // Some attributes are constructed with empty-string values when not defined - attrHandle.id = attrHandle.name = attrHandle.coords = - function( elem, name, isXML ) { - var ret; - if ( !isXML ) { - return (ret = elem.getAttributeNode( name )) && ret.value !== "" ? - ret.value : - null; - } - }; - - // Fixing value retrieval on a button requires this module - jQuery.valHooks.button = { - get: function( elem, name ) { - var ret = elem.getAttributeNode( name ); - if ( ret && ret.specified ) { - return ret.value; - } - }, - set: nodeHook.set - }; - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - set: function( elem, value, name ) { - nodeHook.set( elem, value === "" ? false : value, name ); - } - }; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; - } - } - }; - }); -} - if ( !support.style ) { jQuery.attrHooks.style = { get: function( elem ) { diff --git a/src/attributes/prop.js b/src/attributes/prop.js index 92fa8c3b3..991e509c2 100644 --- a/src/attributes/prop.js +++ b/src/attributes/prop.js @@ -80,22 +80,6 @@ jQuery.extend({ } }); -// Some attributes require a special call on IE -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !support.hrefNormalized ) { - // href/src property should get the full normalized URL (#10299/#12915) - jQuery.each([ "href", "src" ], function( i, name ) { - jQuery.propHooks[ name ] = { - get: function( elem ) { - return elem.getAttribute( name, 4 ); - } - }; - }); -} - -// Support: Safari, IE9+ -// mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it if ( !support.optSelected ) { jQuery.propHooks.selected = { get: function( elem ) { @@ -129,9 +113,4 @@ jQuery.each([ jQuery.propFix[ this.toLowerCase() ] = this; }); -// IE6/7 call enctype encoding -if ( !support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} - }); diff --git a/src/attributes/support.js b/src/attributes/support.js index 665e836f6..044e23823 100644 --- a/src/attributes/support.js +++ b/src/attributes/support.js @@ -8,8 +8,7 @@ define([ // Setup div = document.createElement( "div" ); - div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; + div.innerHTML = " a"; a = div.getElementsByTagName("a")[ 0 ]; // First batch of tests. @@ -19,28 +18,18 @@ define([ a.style.cssText = "top:1px"; - // Test setAttribute on camelCase class. - // If it works, we need attrFixes when doing get/setAttribute (ie6/7) - support.getSetAttribute = div.className !== "t"; - // Get the style information from getAttribute // (IE uses .cssText instead) support.style = /top/.test( a.getAttribute("style") ); - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - support.hrefNormalized = a.getAttribute("href") === "/a"; - // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) support.checkOn = !!input.value; + // Support: IE8-11+ // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + // (IE defaults to false instead of true if it's in an optgroup) support.optSelected = opt.selected; - // Tests for enctype support on a form (#6743) - support.enctype = !!document.createElement("form").enctype; - // Make sure that the options inside disabled selects aren't marked as disabled // (WebKit marks them as disabled) select.disabled = true; diff --git a/src/attributes/val.js b/src/attributes/val.js index c51a1a3b8..d9dd836cb 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -96,7 +96,8 @@ jQuery.extend({ for ( ; i < max; i++ ) { option = options[ i ]; - // oldIE doesn't update selected after form reset (#2551) + // Support: IE<10 + // IE8-9 doesn't update selected after form reset (#2551) if ( ( option.selected || i === index ) && // Don't return options that are disabled or in a disabled optgroup ( support.optDisabled ? @@ -129,24 +130,9 @@ jQuery.extend({ while ( i-- ) { option = options[ i ]; - - if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) { - - // Support: IE6 - // When new option element is added to select box we need to - // force reflow of newly added node in order to workaround delay - // of initialization properties - try { - option.selected = optionSet = true; - - } catch ( _ ) { - - // Will be executed only in IE6 - option.scrollHeight; - } - - } else { - option.selected = false; + if ( (option.selected = + jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0) ) { + optionSet = true; } } @@ -172,8 +158,6 @@ jQuery.each([ "radio", "checkbox" ], function() { }; if ( !support.checkOn ) { jQuery.valHooks[ this ].get = function( elem ) { - // Support: Webkit - // "" is returned instead of "on" if a value isn't specified return elem.getAttribute("value") === null ? "on" : elem.value; }; } diff --git a/src/core.js b/src/core.js index 27162f84a..5251dc639 100644 --- a/src/core.js +++ b/src/core.js @@ -285,9 +285,7 @@ jQuery.extend({ script.text = data; - // Support: IE6 - // Circumvent bugs with base elements (#2709 and #4378) by prepending - head.insertBefore( script, head.firstChild ); + head.appendChild( script ); head.removeChild( script ); }, diff --git a/src/core/init.js b/src/core/init.js index c0f50d0c0..94f95391b 100644 --- a/src/core/init.js +++ b/src/core/init.js @@ -27,8 +27,8 @@ var rootjQuery, // Handle HTML strings if ( typeof selector === "string" ) { - if ( selector.charAt(0) === "<" && - selector.charAt( selector.length - 1 ) === ">" && + if ( selector[ 0 ] === "<" && + selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { // Assume that strings that start and end with <> are HTML and skip the regex check @@ -73,16 +73,8 @@ var rootjQuery, } else { elem = document.getElementById( match[2] ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object + if ( elem ) { + // Inject the element directly into the jQuery object this.length = 1; this[0] = elem; } diff --git a/src/core/ready.js b/src/core/ready.js index 095e6daeb..10bebf648 100644 --- a/src/core/ready.js +++ b/src/core/ready.js @@ -71,6 +71,7 @@ function detach() { document.removeEventListener( "DOMContentLoaded", completed, false ); window.removeEventListener( "load", completed, false ); + // Support: IE<9 } else { document.detachEvent( "onreadystatechange", completed ); window.detachEvent( "onload", completed ); @@ -114,6 +115,7 @@ jQuery.ready.promise = function( obj ) { // A fallback to window.onload, that will always work window.addEventListener( "load", completed, false ); + // Support: IE<9 // If IE event model is used } else { // Ensure firing before onload, maybe late but safe also for iframes @@ -121,38 +123,12 @@ jQuery.ready.promise = function( obj ) { // A fallback to window.onload, that will always work window.attachEvent( "onload", completed ); - - // If IE and not a frame - // continually check to see if the document is ready - var top = false; - - try { - top = window.frameElement == null && document.documentElement; - } catch ( e ) {} - - if ( top && top.doScroll ) { - (function doScrollCheck() { - if ( !jQuery.isReady ) { - - try { - // Use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - top.doScroll("left"); - } catch ( e ) { - return setTimeout( doScrollCheck, 50 ); - } - - // detach all dom ready events - detach(); - - // and execute any waiting functions - jQuery.ready(); - } - })(); - } } } return readyList.promise( obj ); }; +// Kick off the DOM ready check even if the user does not +jQuery.ready.promise(); + }); diff --git a/src/css.js b/src/css.js index c434fd1b7..a12a87408 100644 --- a/src/css.js +++ b/src/css.js @@ -38,7 +38,7 @@ var fontWeight: "400" }, - cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; + cssPrefixes = [ "Webkit", "Moz", "ms" ]; // BuildExclude curCSS = curCSS.curCSS; @@ -52,7 +52,7 @@ function vendorPropName( style, name ) { } // check for vendor prefixed names - var capName = name.charAt(0).toUpperCase() + name.slice(1), + var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), origName = name, i = cssPrefixes.length; @@ -174,8 +174,7 @@ function getWidthOrHeight( elem, name, extra ) { var valueIsBorderBox = true, val = name === "width" ? elem.offsetWidth : elem.offsetHeight, styles = getStyles( elem ), - isBorderBox = support.boxSizing && - jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; // some non-html elements return undefined for offsetWidth, so check for null/undefined // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 @@ -302,7 +301,7 @@ jQuery.extend({ if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { - // Support: IE + // Support: IE<9 // Swallow errors from 'invalid' CSS values (#5509) try { style[ name ] = value; @@ -380,8 +379,7 @@ jQuery.each([ "height", "width" ], function( i, name ) { elem, name, extra, - support.boxSizing && - jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", styles ) : 0 ); @@ -437,11 +435,10 @@ if ( !support.opacity ) { }; } +// Support: Android 2.3 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, function( elem, computed ) { if ( computed ) { - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - // Work around by temporarily setting element display to inline-block return jQuery.swap( elem, { "display": "inline-block" }, curCSS, [ elem, "marginRight" ] ); } diff --git a/src/css/curCSS.js b/src/css/curCSS.js index 66602cc80..0b8f25997 100644 --- a/src/css/curCSS.js +++ b/src/css/curCSS.js @@ -36,12 +36,11 @@ if ( window.getComputedStyle ) { ret = jQuery.style( elem, name ); } + // Support: Android 4.0-4.3 // A tribute to the "awesome hack by Dean Edwards" - // Chrome < 17 and Safari 5.0 uses "computed value" - // instead of "used value" for margin-right - // Safari 5.1.7 (at least) returns percentage for a larger set of values, - // but width seems to be reliably pixels - // this is against the CSSOM draft spec: + // Android Browser returns percentage for some values, + // but width seems to be reliably pixels. + // This is against the CSSOM draft spec: // http://dev.w3.org/csswg/cssom/#resolved-values if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { @@ -61,7 +60,7 @@ if ( window.getComputedStyle ) { } } - // Support: IE + // Support: IE9-11+ // IE returns zIndex value as an integer. return ret === undefined ? ret : @@ -115,7 +114,7 @@ if ( window.getComputedStyle ) { } } - // Support: IE + // Support: IE<9 // IE returns zIndex value as an integer. return ret === undefined ? ret : diff --git a/src/css/hiddenVisibleSelectors.js b/src/css/hiddenVisibleSelectors.js index 027fd179d..9f27b8b9e 100644 --- a/src/css/hiddenVisibleSelectors.js +++ b/src/css/hiddenVisibleSelectors.js @@ -6,11 +6,9 @@ define([ ], function( jQuery, support ) { jQuery.expr.filters.hidden = function( elem ) { - // Support: Opera <= 12.12 - // Opera reports offsetWidths and offsetHeights less than zero on some elements // Use OR instead of AND as the element is not visible if either is true // See tickets #10406 and #13132 - return elem.offsetWidth <= 0 || elem.offsetHeight <= 0 || + return !elem.offsetWidth || !elem.offsetHeight || (!support.reliableHiddenOffsets() && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); }; diff --git a/src/css/support.js b/src/css/support.js index 05f5cc866..e8f8dd4b7 100644 --- a/src/css/support.js +++ b/src/css/support.js @@ -33,11 +33,6 @@ define([ div.cloneNode( true ).style.backgroundClip = ""; support.clearCloneStyle = div.style.backgroundClip === "content-box"; - // Support: Firefox<29, Android 2.3 - // Vendor-prefix box-sizing - support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" || - style.WebkitBoxSizing === ""; - jQuery.extend(support, { reliableHiddenOffsets: function() { if ( reliableHiddenOffsetsVal == null ) { @@ -71,9 +66,9 @@ define([ function computeStyleTests() { // Minified: var b,c,d,j - var div, body, container, contents; + var div, container, contents, + body = document.body; - body = document.getElementsByTagName( "body" )[ 0 ]; if ( !body || !body.style ) { // Test fired too early or in an unsupported environment, exit. return; @@ -86,10 +81,10 @@ define([ body.appendChild( container ).appendChild( div ); div.style.cssText = - // Support: Firefox<29, Android 2.3 + // Support: Android 2.3 // Vendor-prefix box-sizing - "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + - "box-sizing:border-box;display:block;margin-top:1%;top:1%;" + + "-webkit-box-sizing:border-box;box-sizing:border-box;" + + "display:block;margin-top:1%;top:1%;" + "border:1px;padding:1px;width:4px;position:absolute"; // Support: IE<9 @@ -111,10 +106,10 @@ define([ // Reset CSS: box-sizing; display; margin; border; padding contents.style.cssText = div.style.cssText = - // Support: Firefox<29, Android 2.3 + // Support: Android 2.3 // Vendor-prefix box-sizing - "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + - "box-sizing:content-box;display:block;margin:0;border:0;padding:0"; + "-webkit-box-sizing:content-box;box-sizing:content-box;" + + "display:block;margin:0;border:0;padding:0"; contents.style.marginRight = contents.style.width = "0"; div.style.width = "1px"; @@ -124,7 +119,7 @@ define([ div.removeChild( contents ); } - // Support: IE8 + // Support: IE<9 // Check if table cells still have offsetWidth/Height when they are set // to display:none and there are still other visible table cells in a // table row; if so, offsetWidth/Height are not reliable for use when diff --git a/src/dimensions.js b/src/dimensions.js index 95f327b0f..08bf60ee0 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -29,7 +29,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], // whichever is greatest - // unfortunately, this causes bug #3838 in IE6/8 only, + // unfortunately, this causes bug #3838 in IE8 only, // but there is currently no good, small way to fix it. return Math.max( elem.body[ "scroll" + name ], doc[ "scroll" + name ], diff --git a/src/effects.js b/src/effects.js index 189658163..42a9684b8 100644 --- a/src/effects.js +++ b/src/effects.js @@ -4,7 +4,6 @@ define([ "./css/var/cssExpand", "./css/var/isHidden", "./css/defaultDisplay", - "./effects/support", "./core/init", "./effects/Tween", @@ -12,7 +11,7 @@ define([ "./css", "./deferred", "./traversing" -], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, support ) { +], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay ) { var fxNow, timerId, @@ -177,26 +176,17 @@ function defaultPrefilter( elem, props, opts ) { jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { - - // inline-level elements accept inline-block; - // block-level elements need to be inline with layout - if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) { - style.display = "inline-block"; - } else { - style.zoom = 1; - } + style.display = "inline-block"; } } if ( opts.overflow ) { style.overflow = "hidden"; - if ( !support.shrinkWrapBlocks() ) { - anim.always(function() { - style.overflow = opts.overflow[ 0 ]; - style.overflowX = opts.overflow[ 1 ]; - style.overflowY = opts.overflow[ 2 ]; - }); - } + anim.always(function() { + style.overflow = opts.overflow[ 0 ]; + style.overflowX = opts.overflow[ 1 ]; + style.overflowY = opts.overflow[ 2 ]; + }); } // show/hide pass @@ -320,7 +310,8 @@ function Animation( elem, properties, options ) { } var currentTime = fxNow || createFxNow(), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), - // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497) + // Support: Android 2.3 + // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) temp = remaining / animation.duration || 0, percent = 1 - temp, index = 0, diff --git a/src/effects/support.js b/src/effects/support.js deleted file mode 100644 index c3ba17b5f..000000000 --- a/src/effects/support.js +++ /dev/null @@ -1,54 +0,0 @@ -define([ - "../var/support" -], function( support ) { - -(function() { - var shrinkWrapBlocksVal; - - support.shrinkWrapBlocks = function() { - if ( shrinkWrapBlocksVal != null ) { - return shrinkWrapBlocksVal; - } - - // Will be changed later if needed. - shrinkWrapBlocksVal = false; - - // Minified: var b,c,d - var div, body, container; - - body = document.getElementsByTagName( "body" )[ 0 ]; - if ( !body || !body.style ) { - // Test fired too early or in an unsupported environment, exit. - return; - } - - // Setup - div = document.createElement( "div" ); - container = document.createElement( "div" ); - container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; - body.appendChild( container ).appendChild( div ); - - // Support: IE6 - // Check if elements with layout shrink-wrap their children - if ( typeof div.style.zoom !== "undefined" ) { - // Reset CSS: box-sizing; display; margin; border - div.style.cssText = - // Support: Firefox<29, Android 2.3 - // Vendor-prefix box-sizing - "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + - "box-sizing:content-box;display:block;margin:0;border:0;" + - "padding:1px;width:1px;zoom:1"; - div.appendChild( document.createElement( "div" ) ).style.width = "5px"; - shrinkWrapBlocksVal = div.offsetWidth !== 3; - } - - body.removeChild( container ); - - return shrinkWrapBlocksVal; - }; - -})(); - -return support; - -}); diff --git a/src/event.js b/src/event.js index f6759fd5f..ce8b71e30 100644 --- a/src/event.js +++ b/src/event.js @@ -340,8 +340,9 @@ jQuery.event = { jQuery.acceptData( elem ) ) { // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. // Don't do default actions on window, that's where global variables be (#6170) + // Support: IE<9 + // Can't use an .isFunction() check here because IE8 fails that test. if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { // Don't re-trigger an onFOO event when we call its FOO() method @@ -514,7 +515,7 @@ jQuery.event = { event.target = originalEvent.srcElement || document; } - // Support: Chrome 23+, Safari? + // Support: Safari 6.0+ // Target should not be a text node (#504, #13143) if ( event.target.nodeType === 3 ) { event.target = event.target.parentNode; @@ -677,7 +678,7 @@ jQuery.removeEvent = document.removeEventListener ? if ( elem.detachEvent ) { - // #8545, #7054, preventing memory leaks for custom events in IE6-8 + // #8545, #7054, preventing memory leaks for custom events in IE8 // detachEvent needed property on element, by name of that event, // to properly expose it to GC if ( typeof elem[ name ] === "undefined" ) { diff --git a/src/manipulation.js b/src/manipulation.js index 63fa1088d..003d05fe0 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -36,7 +36,6 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" + rleadingWhitespace = /^\s+/, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rtagName = /<([\w:]+)/, - rtbody = /", "" ], td: [ 3, "", "
" ], - // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, + // IE8 can't serialize link, script, style, or any html5 (NoScope) tags, // unless wrapped in a div with non-breaking characters in front of it. _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
", "
" ] }, @@ -91,14 +90,6 @@ function getAll( context, tag ) { found; } -// Used in buildFragment, fixes the defaultChecked property -function fixDefaultChecked( elem ) { - if ( rcheckableType.test( elem.type ) ) { - elem.defaultChecked = elem.checked; - } -} - -// Support: IE<8 // Manipulating tables requires a tbody function manipulationTarget( elem, content ) { return jQuery.nodeName( elem, "table" ) && @@ -175,7 +166,6 @@ function fixCloneNodeIssues( src, dest ) { nodeName = dest.nodeName.toLowerCase(); - // IE6-8 copies events bound via attachEvent when using cloneNode. if ( !support.noCloneEvent && dest[ jQuery.expando ] ) { data = jQuery._data( dest ); @@ -187,45 +177,26 @@ function fixCloneNodeIssues( src, dest ) { dest.removeAttribute( jQuery.expando ); } + // Support: IE<9 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text if ( nodeName === "script" && dest.text !== src.text ) { disableScript( dest ).text = src.text; restoreScript( dest ); - // IE6-10 improperly clones children of object elements using classid. - // IE10 throws NoModificationAllowedError if parent is null, #12132. - } else if ( nodeName === "object" ) { - if ( dest.parentNode ) { - dest.outerHTML = src.outerHTML; - } - - // This path appears unavoidable for IE9. When cloning an object - // element in IE9, the outerHTML strategy above is not sufficient. - // If the src has innerHTML and the destination does not, - // copy the src.innerHTML into the dest.innerHTML. #10324 - if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { - dest.innerHTML = src.innerHTML; - } - + // Support: IE<9 + // IE8 fails to persist the checked state of a cloned checkbox + // or radio button. } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { - // IE6-8 fails to persist the checked state of a cloned checkbox - // or radio button. Worse, IE6-7 fail to give the cloned element - // a checked appearance if the defaultChecked value isn't also set + dest.checked = src.checked; - dest.defaultChecked = dest.checked = src.checked; - - // IE6-7 get confused and end up setting the value of a cloned - // checkbox/radio button to an empty string instead of "on" - if ( dest.value !== src.value ) { - dest.value = src.value; - } - - // IE6-8 fails to return the selected option to the default selected + // Support: IE<9 + // IE8 fails to return the selected option to the default selected // state when cloning options } else if ( nodeName === "option" ) { dest.defaultSelected = dest.selected = src.defaultSelected; - // IE6-8 fails to set the defaultValue to the correct value when + // Support: IE<9 + // IE8 fails to set the defaultValue to the correct value when // cloning other types of input fields } else if ( nodeName === "input" || nodeName === "textarea" ) { dest.defaultValue = src.defaultValue; @@ -292,7 +263,7 @@ jQuery.extend({ buildFragment: function( elems, context, scripts, selection ) { var j, elem, contains, - tmp, tag, tbody, wrap, + tmp, tag, wrap, l = elems.length, // Ensure a safe fragment @@ -335,28 +306,6 @@ jQuery.extend({ nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); } - // Remove IE's autoinserted from table fragments - if ( !support.tbody ) { - - // String was a , *may* have spurious - elem = tag === "table" && !rtbody.test( elem ) ? - tmp.firstChild : - - // String was a bare or - wrap[1] === "
" && !rtbody.test( elem ) ? - tmp : - 0; - - j = elem && elem.childNodes.length; - while ( j-- ) { - if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && - !tbody.childNodes.length ) { - - elem.removeChild( tbody ); - } - } - } - jQuery.merge( nodes, tmp.childNodes ); // Fix #12392 for WebKit and IE > 9 @@ -378,12 +327,6 @@ jQuery.extend({ safe.removeChild( tmp ); } - // Reset defaultChecked for any radios and checkboxes - // about to be appended to the DOM in IE 6/7 (#8060) - if ( !support.appendChecked ) { - jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); - } - i = 0; while ( (elem = nodes[ i++ ]) ) { @@ -687,6 +630,8 @@ jQuery.fn.extend({ // Keep references to cloned scripts for later restoration if ( hasScripts ) { + // Support: Android<4.1, PhantomJS<2 + // push.apply(_, arraylike) throws on ancient WebKit jQuery.merge( scripts, getAll( node, "script" ) ); } } @@ -749,7 +694,8 @@ jQuery.each({ elems = i === last ? this : this.clone(true); jQuery( insert[i] )[ original ]( elems ); - // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() + // Support: IE<9, Android<4.1, PhantomJS<2 + // .get() because push.apply(_, arraylike) throws on ancient WebKit push.apply( ret, elems.get() ); } diff --git a/src/manipulation/support.js b/src/manipulation/support.js index 3ac54f4bb..27e0fb1de 100644 --- a/src/manipulation/support.js +++ b/src/manipulation/support.js @@ -3,21 +3,15 @@ define([ ], function( support ) { (function() { - // Minified: var a,b,c - var input = document.createElement( "input" ), - div = document.createElement( "div" ), + var div = document.createElement( "div" ), fragment = document.createDocumentFragment(); // Setup - div.innerHTML = "
a"; + div.innerHTML = " "; // IE strips leading whitespace when .innerHTML is used support.leadingWhitespace = div.firstChild.nodeType === 3; - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - support.tbody = !div.getElementsByTagName( "tbody" ).length; - // Make sure that link elements get serialized correctly by innerHTML // This requires a wrapper element in IE support.htmlSerialize = !!div.getElementsByTagName( "link" ).length; @@ -27,15 +21,8 @@ define([ support.html5Clone = document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav>"; - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - input.type = "checkbox"; - input.checked = true; - fragment.appendChild( input ); - support.appendChecked = input.checked; - // Make sure textarea (and checkbox) defaultValue is properly cloned - // Support: IE6-IE11+ + // Support: IE8-IE11+ div.innerHTML = ""; support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; @@ -43,8 +30,8 @@ define([ fragment.appendChild( div ); div.innerHTML = ""; - // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 - // old WebKit doesn't clone checked state correctly in fragments + // Support: Android<4.2 + // Older WebKit doesn't clone checked state correctly in fragments support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; // Support: IE<9 diff --git a/src/offset.js b/src/offset.js index eb3c1f119..37d7c34cf 100644 --- a/src/offset.js +++ b/src/offset.js @@ -103,11 +103,7 @@ jQuery.fn.extend({ return box; } - // If we don't have gBCR, just use 0,0 rather than error - // BlackBerry 5, iOS 3 (original iPhone) - if ( typeof elem.getBoundingClientRect !== "undefined" ) { - box = elem.getBoundingClientRect(); - } + box = elem.getBoundingClientRect(); win = getWindow( doc ); return { top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ), diff --git a/src/support.js b/src/support.js index 49cbd2a21..cb5386a7b 100644 --- a/src/support.js +++ b/src/support.js @@ -15,43 +15,5 @@ for ( i in jQuery( support ) ) { support.ownLast = i !== "0"; // Note: most support tests are defined in their respective modules. -// false until the test is run -support.inlineBlockNeedsLayout = false; - -// Execute ASAP in case we need to set body.style.zoom -jQuery(function() { - // Minified: var a,b,c,d - var val, div, body, container; - - body = document.getElementsByTagName( "body" )[ 0 ]; - if ( !body || !body.style ) { - // Return for frameset docs that don't have a body - return; - } - - // Setup - div = document.createElement( "div" ); - container = document.createElement( "div" ); - container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; - body.appendChild( container ).appendChild( div ); - - if ( typeof div.style.zoom !== "undefined" ) { - // Support: IE<8 - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1"; - - support.inlineBlockNeedsLayout = val = div.offsetWidth === 3; - if ( val ) { - // Prevent IE 6 from affecting layout for positioned elements #11048 - // Prevent IE from shrinking the body in IE 7 mode #12869 - // Support: IE<8 - body.style.zoom = 1; - } - } - - body.removeChild( container ); -}); }); diff --git a/test/data/css/cssWidthBeforeDocReady.html b/test/data/css/cssWidthBeforeDocReady.html index 3bdd1b5ab..c45b6811a 100644 --- a/test/data/css/cssWidthBeforeDocReady.html +++ b/test/data/css/cssWidthBeforeDocReady.html @@ -5,7 +5,6 @@
diff --git a/test/data/support/shrinkWrapBlocks.html b/test/data/support/shrinkWrapBlocks.html deleted file mode 100644 index d781423ec..000000000 --- a/test/data/support/shrinkWrapBlocks.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - -
- -
- - - diff --git a/test/data/testsuite.css b/test/data/testsuite.css index d9909ddcc..de5f3fb00 100644 --- a/test/data/testsuite.css +++ b/test/data/testsuite.css @@ -1,7 +1,7 @@ /* for testing opacity set in styles in IE */ ol#empty { opacity: 0; - filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); + -ms-filter: "Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff')"; } div#fx-tests h4 { @@ -47,7 +47,7 @@ div.largeheight { } div.largeopacity { - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100); + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=100)"; } div.medwidth { @@ -60,7 +60,7 @@ div.medheight { div.medopacity { opacity: 0.5; - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50); + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; } div.nowidth { @@ -73,7 +73,7 @@ div.noheight { div.noopacity { opacity: 0; - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=0)"; } div.hidden { @@ -143,8 +143,8 @@ dfn { display: none; } /* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */ body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif) no-repeat -1000px 0; } -/* #6652 REMOVE FILTER:ALPHA(OPACITY=100) AFTER ANIMATION */ -#t6652 div { filter: alpha(opacity=50); } +/* #6652 Remove -ms-filter: "alpha(opacity=100)" after animation */ +#t6652 div { -ms-filter: "alpha(opacity=50)"; } /* #10501 */ section { background:#f0f; display:block; } diff --git a/test/unit/ajax.js b/test/unit/ajax.js index c63fd69d9..da1f6ecb9 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1014,9 +1014,7 @@ module( "ajax", { " (no cache)": false }, function( label, cache ) { - var isOpera = !!window.opera; - - asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 3, function() { + asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 4, function() { var url = "data/if_modified_since.php?ts=" + ifModifiedNow++; jQuery.ajax({ @@ -1030,33 +1028,15 @@ module( "ajax", { url: url, ifModified: true, cache: cache, - success: function( data, status ) { - if ( data === "FAIL" ) { - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." ); - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." ); - } else { - strictEqual( status, "notmodified" ); - ok( data == null, "response body should be empty" ); - } - start(); + success: function( data, status, jqXHR ) { + strictEqual( status, "notmodified", "Following status is 'notmodified'" ); + strictEqual( jqXHR.status, 304, "XHR status is 304" ); + equal( data, null, "no response body is given" ); }, - error: function() { - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - ok( isOpera, "error" ); + complete: function() { start(); } }); - }, - error: function() { - strictEqual( false, "error" ); - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - start(); } }); }); @@ -1076,31 +1056,13 @@ module( "ajax", { ifModified: true, cache: cache, success: function( data, status ) { - if ( data === "FAIL" ) { - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." ); - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." ); - } else { - strictEqual( status, "notmodified" ); - ok( data == null, "response body should be empty" ); - } - start(); + strictEqual( status, "notmodified" ); + ok( data == null, "response body should be empty" ); }, - error: function() { - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - ok( isOpera, "error" ); + complete: function() { start(); } }); - }, - error: function() { - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - start(); } }); }); diff --git a/test/unit/attributes.js b/test/unit/attributes.js index d76b0e260..55bdfffbd 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -46,10 +46,6 @@ test( "jQuery.propFix integrity test", function() { "contenteditable": "contentEditable" }; - if ( !jQuery.support.enctype ) { - props.enctype = "encoding"; - } - deepEqual( props, jQuery.propFix, "jQuery.propFix passes integrity check" ); }); @@ -594,8 +590,7 @@ test( "removeAttr(String)", function() { $first = jQuery("
"); equal( $first.attr("Case"), "mixed", "case of attribute doesn't matter" ); $first.removeAttr("Case"); - // IE 6/7 return empty string here, not undefined - ok( !$first.attr("Case"), "mixed-case attribute was removed" ); + equal( $first.attr("Case"), undefined, "mixed-case attribute was removed" ); }); test( "removeAttr(String) in XML", function() { diff --git a/test/unit/css.js b/test/unit/css.js index 364249a31..a4ee14cf6 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -231,8 +231,6 @@ test("css(String, Object)", function() { j = jQuery("#nonnodes").contents(); j.css("overflow", "visible"); equal( j.css("overflow"), "visible", "Check node,textnode,comment css works" ); - // opera sometimes doesn't update 'display' correctly, see #2037 - jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML; equal( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" ); div = jQuery("#nothiddendiv"); @@ -297,11 +295,7 @@ if ( !jQuery.support.opacity ) { test2 = test.find( "div" ).css( "opacity", 1 ); function hasFilter( elem ) { - var match = rfilter.exec( elem[0].style.cssText ); - if ( match ) { - return true; - } - return false; + return !!rfilter.exec( elem[0].style.cssText ); } expect( 2 ); ok( !hasFilter( test ), "Removed filter attribute on element without filter in stylesheet" ); @@ -455,7 +449,7 @@ test("show();", function() { expect( 18 ); - var hiddendiv, div, pass, old, test; + var hiddendiv, div, pass, test; hiddendiv = jQuery("div.hidden"); equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none"); @@ -478,10 +472,7 @@ test("show();", function() { ok( pass, "Show" ); // #show-tests * is set display: none in CSS - jQuery("#qunit-fixture").append("

"); - - old = jQuery("#test-table").show().css("display") !== "table"; - jQuery("#test-table").remove(); + jQuery("#qunit-fixture").append("

"); test = { "div" : "block", @@ -490,14 +481,14 @@ test("show();", function() { "code" : "inline", "pre" : "block", "span" : "inline", - "table" : old ? "block" : "table", - "thead" : old ? "block" : "table-header-group", - "tbody" : old ? "block" : "table-row-group", - "tr" : old ? "block" : "table-row", - "th" : old ? "block" : "table-cell", - "td" : old ? "block" : "table-cell", + "table" : "table", + "thead" : "table-header-group", + "tbody" : "table-row-group", + "tr" : "table-row", + "th" : "table-cell", + "td" : "table-cell", "ul" : "block", - "li" : old ? "block" : "list-item" + "li" : "list-item" }; jQuery.each(test, function(selector, expected) { @@ -848,8 +839,8 @@ test("Do not append px (#9548, #12990)", function() { test("css('width') and css('height') should respect box-sizing, see #11004", function() { expect( 4 ); - // Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions). - var el_dis = jQuery("
test
"), + // Support: Android 2.3 (-webkit-box-sizing). + var el_dis = jQuery("
test
"), el = el_dis.clone().appendTo("#qunit-fixture"); equal( el.css("width"), el.css("width", el.css("width")).css("width"), "css('width') is not respecting box-sizing, see #11004"); @@ -930,13 +921,13 @@ test( "css opacity consistency across browsers (#12685)", function() { fixture = jQuery("#qunit-fixture"); // Append style element - jQuery("").appendTo( fixture ); + jQuery("").appendTo( fixture ); el = jQuery("
").appendTo(fixture); - equal( Math.round( el.css("opacity") * 100 ), 10, "opacity from style sheet (filter:alpha with spaces)" ); + equal( Math.round( el.css("opacity") * 100 ), 10, "opacity from style sheet (-ms-filter:alpha with spaces)" ); el.removeClass("opacityWithSpaces_t12685").addClass("opacityNoSpaces_t12685"); - equal( Math.round( el.css("opacity") * 100 ), 20, "opacity from style sheet (filter:alpha without spaces)" ); + equal( Math.round( el.css("opacity") * 100 ), 20, "opacity from style sheet (-ms-filter:alpha without spaces)" ); el.css( "opacity", 0.3 ); equal( Math.round( el.css("opacity") * 100 ), 30, "override opacity" ); el.css( "opacity", "" ); diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 602e97099..c3bf71a63 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -415,8 +415,8 @@ test( "getters on non elements should return null", function() { test("setters with and without box-sizing:border-box", function(){ expect(20); - // Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions). - var el_bb = jQuery("
test
").appendTo("#qunit-fixture"), + // Support: Android 2.3 (-webkit-box-sizing). + var el_bb = jQuery("
test
").appendTo("#qunit-fixture"), el = jQuery("
test
").appendTo("#qunit-fixture"), expected = 100; diff --git a/test/unit/effects.js b/test/unit/effects.js index 23a9a50ee..bb5b0ce7d 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -47,7 +47,7 @@ test("show() basic", 2, function() { }); test("show()", 27, function () { - var div, speeds, old, test, + var div, speeds, test, displaysActual, displaysExpected, hiddendiv = jQuery("div.hidden"); @@ -97,10 +97,7 @@ test("show()", 27, function () { QUnit.expectJqData( this, div, "olddisplay" ); // #show-tests * is set display: none in CSS - jQuery("#qunit-fixture").append("

"); - - old = jQuery("#test-table").show().css("display") !== "table"; - jQuery("#test-table").remove(); + jQuery("#qunit-fixture").append("

"); test = { "div" : "block", @@ -109,14 +106,14 @@ test("show()", 27, function () { "code" : "inline", "pre" : "block", "span" : "inline", - "table" : old ? "block" : "table", - "thead" : old ? "block" : "table-header-group", - "tbody" : old ? "block" : "table-row-group", - "tr" : old ? "block" : "table-row", - "th" : old ? "block" : "table-cell", - "td" : old ? "block" : "table-cell", + "table" : "table", + "thead" : "table-header-group", + "tbody" : "table-row-group", + "tr" : "table-row", + "th" : "table-cell", + "td" : "table-cell", "ul" : "block", - "li" : old ? "block" : "list-item" + "li" : "list-item" }; jQuery.each(test, function(selector, expected) { @@ -136,31 +133,27 @@ test("show(Number) - other displays", function() { // #show-tests * is set display: none in CSS - jQuery("#qunit-fixture").append("

"); - - var test, - old = jQuery("#test-table").show().css("display") !== "table"; - jQuery("#test-table").remove(); + jQuery("#qunit-fixture").append("

"); // Note: inline elements are expected to be inline-block // because we're showing width/height // Can't animate width/height inline // See #14344 - test = { + var test = { "div" : "block", "p" : "block", "a" : "inline-block", "code" : "inline-block", "pre" : "block", "span" : "inline-block", - "table" : old ? "block" : "table", - "thead" : old ? "block" : "table-header-group", - "tbody" : old ? "block" : "table-row-group", - "tr" : old ? "block" : "table-row", - "th" : old ? "block" : "table-cell", - "td" : old ? "block" : "table-cell", + "table" : "table", + "thead" : "table-header-group", + "tbody" : "table-row-group", + "tr" : "table-row", + "th" : "table-cell", + "td" : "table-cell", "ul" : "block", - "li" : old ? "block" : "list-item" + "li" : "list-item" }; jQuery.each(test, function(selector, expected) { @@ -289,52 +282,35 @@ test("animate negative padding", function() { test("animate block as inline width/height", function() { expect(3); - var span = jQuery("").css("display", "inline-block").appendTo("body"), - expected = span.css("display"); + var span = jQuery("").css("display", "inline-block").appendTo("body"); span.remove(); - if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) { + jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() { + equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); + equal( this.offsetWidth, 42, "width was animated" ); + equal( this.offsetHeight, 42, "height was animated" ); + }); - jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() { - equal( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); - equal( this.offsetWidth, 42, "width was animated" ); - equal( this.offsetHeight, 42, "height was animated" ); - }); - - // Browser doesn't support inline-block - } else { - ok( true, "Browser doesn't support inline-block" ); - ok( true, "Browser doesn't support inline-block" ); - ok( true, "Browser doesn't support inline-block" ); - } this.clock.tick( 100 ); }); test("animate native inline width/height", function() { expect(3); - var span = jQuery("").css("display", "inline-block").appendTo("body"), - expected = span.css("display"); + var span = jQuery("").css("display", "inline-block").appendTo("body"); span.remove(); - if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) { - jQuery("#foo").css({ display: "", width: "", height: "" }) - .append("text") - .children("span") - .animate({ width: 42, height: 42 }, 100, function() { - equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); - equal( this.offsetWidth, 42, "width was animated" ); - equal( this.offsetHeight, 42, "height was animated" ); - }); + jQuery("#foo").css({ display: "", width: "", height: "" }) + .append("text") + .children("span") + .animate({ width: 42, height: 42 }, 100, function() { + equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); + equal( this.offsetWidth, 42, "width was animated" ); + equal( this.offsetHeight, 42, "height was animated" ); + }); - // Browser doesn't support inline-block - } else { - ok( true, "Browser doesn't support inline-block" ); - ok( true, "Browser doesn't support inline-block" ); - ok( true, "Browser doesn't support inline-block" ); - } this.clock.tick( 100 ); }); @@ -365,30 +341,24 @@ test( "animate block width/height", function() { this.clock.tick( 100 ); }); -test("animate table width/height", function() { +test( "animate table width/height", function() { expect(1); - var displayMode = jQuery("#table").css("display") !== "table" ? "block" : "table"; - - jQuery("#table").animate({ width: 42, height: 42 }, 100, function() { - equal( jQuery(this).css("display"), displayMode, "display mode is correct" ); + jQuery( "#table" ).animate({ width: 42, height: 42 }, 100, function() { + equal( jQuery( this ).css( "display" ), "table", "display mode is correct" ); }); this.clock.tick( 100 ); }); test("animate table-row width/height", function() { expect(3); - var displayMode, - tr = jQuery("#table") + var tr = jQuery("#table") .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 }) .html("
") .find("tr"); - // IE<8 uses "block" instead of the correct display type - displayMode = tr.css("display") !== "table-row" ? "block" : "table-row"; - tr.animate({ width: 10, height: 10 }, 100, function() { - equal( jQuery(this).css("display"), displayMode, "display mode is correct" ); + equal( jQuery( this ).css( "display" ), "table-row", "display mode is correct" ); equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); }); @@ -398,17 +368,13 @@ test("animate table-row width/height", function() { test("animate table-cell width/height", function() { expect(3); - var displayMode, - td = jQuery( "#table" ) + var td = jQuery( "#table" ) .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 }) .html( "
" ) .find( "td" ); - // IE<8 uses "block" instead of the correct display type - displayMode = td.css( "display" ) !== "table-cell" ? "block" : "table-cell"; - td.animate({ width: 10, height: 10 }, 100, function() { - equal( jQuery(this).css("display"), displayMode, "display mode is correct" ); + equal( jQuery( this ).css( "display" ), "table-cell", "display mode is correct" ); equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); }); @@ -1050,11 +1016,10 @@ jQuery.each({ test("Effects chaining", function() { var remaining = 16, - shrinkwrap = jQuery.support.shrinkWrapBlocks(), props = [ "opacity", "height", "width", "display", "overflow" ], - setup = function( name, selector, hiddenOverflow ) { + setup = function( name, selector ) { var $el = jQuery( selector ); - return $el.data( getProps( $el[0], hiddenOverflow ) ).data( "name", name ); + return $el.data( getProps( $el[0] ) ).data( "name", name ); }, assert = function() { var data = jQuery.data( this ), @@ -1075,21 +1040,19 @@ test("Effects chaining", function() { expect( remaining ); - // We need to pass jQuery.support.shrinkWrapBlocks for all methods that - // set overflow hidden (slide* and show/hide with speed) setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut("fast").fadeIn( "fast", assert ); setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn("fast").fadeOut( "fast", assert ); - setup( ".hide().show()", "#show div", shrinkwrap ).hide("fast").show( "fast", assert ); - setup( ".show().hide()", "#hide div", shrinkwrap ).show("fast").hide( "fast", assert ); - setup( ".show().hide(easing)", "#easehide div", shrinkwrap ).show("fast").hide( "fast", "linear", assert ); - setup( ".toggle().toggle() - in", "#togglein div", shrinkwrap ).toggle("fast").toggle( "fast", assert ); - setup( ".toggle().toggle() - out", "#toggleout div", shrinkwrap ).toggle("fast").toggle( "fast", assert ); - setup( ".toggle().toggle(easing) - out", "#easetoggleout div", shrinkwrap ).toggle("fast").toggle( "fast", "linear", assert ); - setup( ".slideDown().slideUp()", "#slidedown div", shrinkwrap ).slideDown("fast").slideUp( "fast", assert ); - setup( ".slideUp().slideDown()", "#slideup div", shrinkwrap ).slideUp("fast").slideDown( "fast", assert ); - setup( ".slideUp().slideDown(easing)", "#easeslideup div", shrinkwrap ).slideUp("fast").slideDown( "fast", "linear", assert ); - setup( ".slideToggle().slideToggle() - in", "#slidetogglein div", shrinkwrap ).slideToggle("fast").slideToggle( "fast", assert ); - setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div", shrinkwrap ).slideToggle("fast").slideToggle( "fast", assert ); + setup( ".hide().show()", "#show div" ).hide("fast").show( "fast", assert ); + setup( ".show().hide()", "#hide div" ).show("fast").hide( "fast", assert ); + setup( ".show().hide(easing)", "#easehide div" ).show("fast").hide( "fast", "linear", assert ); + setup( ".toggle().toggle() - in", "#togglein div" ).toggle("fast").toggle( "fast", assert ); + setup( ".toggle().toggle() - out", "#toggleout div" ).toggle("fast").toggle( "fast", assert ); + setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle("fast").toggle( "fast", "linear", assert ); + setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown("fast").slideUp( "fast", assert ); + setup( ".slideUp().slideDown()", "#slideup div" ).slideUp("fast").slideDown( "fast", assert ); + setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp("fast").slideDown( "fast", "linear", assert ); + setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle("fast").slideToggle( "fast", assert ); + setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle("fast").slideToggle( "fast", assert ); setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle("fast").fadeToggle( "fast", assert ); setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle("fast").fadeToggle( "fast", assert ); setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", assert ); @@ -1912,12 +1875,8 @@ test( "Animate properly sets overflow hidden when animating width/height (#12117 equal( div.css( "overflow" ), "hidden", "overflow: hidden set when animating " + prop + " to " + value ); div.stop(); - if ( jQuery.support.shrinkWrapBlocks ) { - ok( true, "cannot restore overflow, shrinkWrapBlocks" ); - } else { - equal( div.css( "overflow" ), "auto", - "overflow: auto restored after animating " + prop + " to " + value ); - } + equal( div.css( "overflow" ), "auto", + "overflow: auto restored after animating " + prop + " to " + value ); }); }); }); diff --git a/test/unit/event.js b/test/unit/event.js index 412fb87bc..61bdc7bca 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -408,15 +408,7 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { e.preventDefault(); }); $main.on("click", "#foo", function(e) { - var orig = e.originalEvent; - - if ( typeof(orig.defaultPrevented) === "boolean" || typeof(orig.returnValue) === "boolean" || orig["getPreventDefault"] ) { - equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" ); - - } else { - // Opera < 11 doesn't implement any interface we can use, so give it a pass - ok( true, "isDefaultPrevented not supported by this browser, test skipped" ); - } + equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" ); }); fakeClick( $anchor2 ); $anchor2.off( "click" ); @@ -1432,7 +1424,7 @@ test("Submit event can be stopped (#11049)", function() { form.remove(); }); -// Test beforeunload event only if it supported (i.e. not Opera) +// Test beforeunload event only if it supported. // Support: iOS 7+, Android<4.0 // iOS & old Android have the window.onbeforeunload field but don't support the beforeunload // handler making it impossible to feature-detect the support. @@ -1440,7 +1432,6 @@ if ( window.onbeforeunload === null && !/(ipad|iphone|ipod|android 2\.3)/i.test( navigator.userAgent ) ) { asyncTest("on(beforeunload)", 4, function() { var win, - forIE6 = 0, fired = false, iframe = jQuery("