diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2019-05-13 21:39:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 21:39:56 +0200 |
commit | 3527a3840585e6a359cd712591c9c57398357b9b (patch) | |
tree | 41446f392d9a8984e31297df3252d1b538f4191e /src | |
parent | ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3 (diff) | |
download | jquery-3527a3840585e6a359cd712591c9c57398357b9b.tar.gz jquery-3527a3840585e6a359cd712591c9c57398357b9b.zip |
Core: Remove IE-specific support tests, rely on document.documentMode
Also, update some tests to IE-sniff when deciding whether
to skip a test.
Fixes gh-4386
Closes gh-4387
Diffstat (limited to 'src')
-rw-r--r-- | src/ajax.js | 6 | ||||
-rw-r--r-- | src/attributes/attr.js | 10 | ||||
-rw-r--r-- | src/attributes/prop.js | 17 | ||||
-rw-r--r-- | src/attributes/support.js | 29 | ||||
-rw-r--r-- | src/css.js | 16 | ||||
-rw-r--r-- | src/css/support.js | 60 | ||||
-rw-r--r-- | src/manipulation.js | 12 | ||||
-rw-r--r-- | src/manipulation/support.js | 28 | ||||
-rw-r--r-- | src/var/isIE.js | 7 |
9 files changed, 41 insertions, 144 deletions
diff --git a/src/ajax.js b/src/ajax.js index 9db26f66c..31880032d 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -458,6 +458,12 @@ jQuery.extend( { if ( !responseHeaders ) { responseHeaders = {}; while ( ( match = rheaders.exec( responseHeadersString ) ) ) { + + // Support: IE 11+ + // `getResponseHeader( key )` in IE doesn't combine all header + // values for the provided key into a single result with values + // joined by commas as other browsers do. Instead, it returns + // them on separate lines. responseHeaders[ match[ 1 ].toLowerCase() + " " ] = ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) .concat( match[ 2 ] ); diff --git a/src/attributes/attr.js b/src/attributes/attr.js index 6b5cbd2c4..cd2b3128b 100644 --- a/src/attributes/attr.js +++ b/src/attributes/attr.js @@ -2,10 +2,10 @@ define( [ "../core", "../core/access", "../core/nodeName", - "./support", "../var/rnothtmlwhite", + "../var/isIE", "../selector" -], function( jQuery, access, nodeName, support, rnothtmlwhite ) { +], function( jQuery, access, nodeName, rnothtmlwhite, isIE ) { "use strict"; @@ -74,8 +74,10 @@ jQuery.extend( { attrHooks: { type: { set: function( elem, value ) { - if ( !support.radioValue && value === "radio" && - nodeName( elem, "input" ) ) { + + // Support: IE <=11+ + // An input loses its value after becoming a radio + if ( isIE && value === "radio" && nodeName( elem, "input" ) ) { var val = elem.value; elem.setAttribute( "type", value ); if ( val ) { diff --git a/src/attributes/prop.js b/src/attributes/prop.js index 8ada707f4..71358aa92 100644 --- a/src/attributes/prop.js +++ b/src/attributes/prop.js @@ -1,9 +1,9 @@ define( [ "../core", "../core/access", - "./support", + "../var/isIE", "../selector" -], function( jQuery, access, support ) { +], function( jQuery, access, isIE ) { "use strict"; @@ -90,14 +90,11 @@ jQuery.extend( { } ); // Support: IE <=11+ -// Accessing the selectedIndex property -// forces the browser to respect setting selected -// on the option -// The getter ensures a default option is selected -// when in an optgroup -// eslint rule "no-unused-expressions" is disabled for this code -// since it considers such accessions noop -if ( !support.optSelected ) { +// Accessing the selectedIndex property forces the browser to respect +// setting selected on the option. The getter ensures a default option +// is selected when in an optgroup. ESLint rule "no-unused-expressions" +// is disabled for this code since it considers such accessions noop. +if ( isIE ) { jQuery.propHooks.selected = { get: function( elem ) { diff --git a/src/attributes/support.js b/src/attributes/support.js deleted file mode 100644 index 78d0040a9..000000000 --- a/src/attributes/support.js +++ /dev/null @@ -1,29 +0,0 @@ -define( [ - "../var/document", - "../var/support" -], function( document, support ) { - -"use strict"; - -( function() { - var input = document.createElement( "input" ), - select = document.createElement( "select" ), - opt = select.appendChild( document.createElement( "option" ) ); - - input.type = "checkbox"; - - // Support: IE <=11+ - // Must access selectedIndex to make default options select - support.optSelected = opt.selected; - - // Support: IE <=11+ - // An input loses its value after becoming a radio - input = document.createElement( "input" ); - input.value = "t"; - input.type = "radio"; - support.radioValue = input.value === "t"; -} )(); - -return support; - -} ); diff --git a/src/css.js b/src/css.js index 91c42624e..2ae0c0c2c 100644 --- a/src/css.js +++ b/src/css.js @@ -2,6 +2,7 @@ define( [ "./core", "./core/access", "./var/rcssNum", + "./var/isIE", "./css/var/rnumnonpx", "./css/var/cssExpand", "./css/isAutoPx", @@ -10,14 +11,13 @@ define( [ "./css/var/swap", "./css/curCSS", "./css/adjustCSS", - "./css/support", "./css/finalPropName", "./core/init", "./core/ready", "./selector" // contains -], function( jQuery, access, rcssNum, rnumnonpx, cssExpand, isAutoPx, cssCamelCase, - getStyles, swap, curCSS, adjustCSS, support, finalPropName ) { +], function( jQuery, access, rcssNum, isIE, rnumnonpx, cssExpand, isAutoPx, + cssCamelCase, getStyles, swap, curCSS, adjustCSS, finalPropName ) { "use strict"; @@ -121,7 +121,7 @@ function getWidthOrHeight( elem, dimension, extra ) { // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). // Fake content-box until we know it's needed to know the true value. - boxSizingNeeded = !support.boxSizingReliable() || extra, + boxSizingNeeded = isIE || extra, isBorderBox = boxSizingNeeded && jQuery.css( elem, "boxSizing", false, styles ) === "border-box", valueIsBorderBox = isBorderBox, @@ -140,11 +140,12 @@ function getWidthOrHeight( elem, dimension, extra ) { // Fall back to offsetWidth/offsetHeight when value is "auto" // This happens for inline elements with no explicit setting (gh-3571) + // // Support: IE 9 - 11+ // Also use offsetWidth/offsetHeight for when box sizing is unreliable // We use getClientRects() to check for hidden/disconnected. // In those cases, the computed value can be trusted to be border-box - if ( ( !support.boxSizingReliable() && isBorderBox || val === "auto" ) && + if ( ( isIE && isBorderBox || val === "auto" ) && elem.getClientRects().length ) { isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; @@ -239,8 +240,9 @@ jQuery.extend( { value += ret && ret[ 3 ] || ( isAutoPx( origName ) ? "px" : "" ); } - // background-* props affect original clone's values - if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { + // Support: IE <=9 - 11+ + // background-* props of a cloned element affect the source element (#8908) + if ( isIE && value === "" && name.indexOf( "background" ) === 0 ) { style[ name ] = "inherit"; } diff --git a/src/css/support.js b/src/css/support.js deleted file mode 100644 index 65763baec..000000000 --- a/src/css/support.js +++ /dev/null @@ -1,60 +0,0 @@ -define( [ - "../core", - "../var/document", - "../var/documentElement", - "../var/support" -], function( jQuery, document, documentElement, support ) { - -"use strict"; - -( function() { - - var boxSizingReliableVal, - container = document.createElement( "div" ), - div = document.createElement( "div" ); - - // Finish early in limited (non-browser) environments - if ( !div.style ) { - return; - } - - // Support: IE <=9 - 11+ - // Style of cloned element affects source element cloned (#8908) - div.style.backgroundClip = "content-box"; - div.cloneNode( true ).style.backgroundClip = ""; - support.clearCloneStyle = div.style.backgroundClip === "content-box"; - - jQuery.extend( support, { - boxSizingReliable: function() { - - // This is a singleton, we need to execute it only once - if ( div ) { - container.style.cssText = "position:absolute;left:-11111px;width:60px;" + - "margin-top:1px;padding:0;border:0"; - div.style.cssText = - "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + - "margin:auto;border:1px;padding:1px;" + - "width:60%;top:1%"; - documentElement.appendChild( container ).appendChild( div ); - - var divStyle = window.getComputedStyle( div ); - - // Support: IE 9 - 11+ - // Detect misreporting of content dimensions for box-sizing:border-box elements - boxSizingReliableVal = Math.round( parseFloat( divStyle.width ) ) === 36; - - documentElement.removeChild( container ); - - // Nullify the div so it wouldn't be stored in the memory and - // it will also be a sign that checks already performed - div = null; - } - - return boxSizingReliableVal; - } - } ); -} )(); - -return support; - -} ); diff --git a/src/manipulation.js b/src/manipulation.js index fb10ef5c2..cca3947ce 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -2,6 +2,7 @@ define( [ "./core", "./core/isAttached", "./var/concat", + "./var/isIE", "./var/push", "./var/rcheckableType", "./core/access", @@ -11,7 +12,6 @@ define( [ "./manipulation/getAll", "./manipulation/setGlobalEval", "./manipulation/buildFragment", - "./manipulation/support", "./data/var/dataPriv", "./data/var/dataUser", @@ -23,9 +23,9 @@ define( [ "./traversing", "./selector", "./event" -], function( jQuery, isAttached, concat, push, rcheckableType, - access, rtagName, rscriptType, - wrapMap, getAll, setGlobalEval, buildFragment, support, +], function( jQuery, isAttached, concat, isIE, push, + rcheckableType, access, rtagName, rscriptType, + wrapMap, getAll, setGlobalEval, buildFragment, dataPriv, dataUser, acceptData, DOMEval, nodeName ) { "use strict"; @@ -222,7 +222,7 @@ jQuery.extend( { inPage = isAttached( elem ); // Fix IE cloning issues - if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + if ( isIE && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) { // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 @@ -233,7 +233,7 @@ jQuery.extend( { // Support: IE <=11+ // IE fails to set the defaultValue to the correct value when - // cloning other types of input fields + // cloning textareas. if ( destElements[ i ].nodeName.toLowerCase() === "textarea" ) { destElements[ i ].defaultValue = srcElements[ i ].defaultValue; } diff --git a/src/manipulation/support.js b/src/manipulation/support.js deleted file mode 100644 index f2ff88e17..000000000 --- a/src/manipulation/support.js +++ /dev/null @@ -1,28 +0,0 @@ -define( [ - "../var/document", - "../var/support" -], function( document, support ) { - -"use strict"; - -( function() { - var fragment = document.createDocumentFragment(), - div = fragment.appendChild( document.createElement( "div" ) ), - input = document.createElement( "input" ); - - // Support: Windows Web Apps (WWA) - // `name` and `type` must use .setAttribute for WWA (#14901) - input.setAttribute( "type", "radio" ); - input.setAttribute( "checked", "checked" ); - - div.appendChild( input ); - - // Support: IE <=11+ - // Make sure textarea (and checkbox) defaultValue is properly cloned - div.innerHTML = "<textarea>x</textarea>"; - support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; -} )(); - -return support; - -} ); diff --git a/src/var/isIE.js b/src/var/isIE.js new file mode 100644 index 000000000..e6a37cb5a --- /dev/null +++ b/src/var/isIE.js @@ -0,0 +1,7 @@ +define( [ + "./document" +], function( document ) { + "use strict"; + + return document.documentMode; +} ); |