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
This commit is contained in:
Michał Gołębiowski-Owczarek 2019-05-13 21:39:56 +02:00 committed by GitHub
parent ccbd6b9342
commit 3527a38405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 287 additions and 459 deletions

View File

@ -458,6 +458,12 @@ jQuery.extend( {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 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() + " " ] =
( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
.concat( match[ 2 ] ); .concat( match[ 2 ] );

View File

@ -2,10 +2,10 @@ define( [
"../core", "../core",
"../core/access", "../core/access",
"../core/nodeName", "../core/nodeName",
"./support",
"../var/rnothtmlwhite", "../var/rnothtmlwhite",
"../var/isIE",
"../selector" "../selector"
], function( jQuery, access, nodeName, support, rnothtmlwhite ) { ], function( jQuery, access, nodeName, rnothtmlwhite, isIE ) {
"use strict"; "use strict";
@ -74,8 +74,10 @@ jQuery.extend( {
attrHooks: { attrHooks: {
type: { type: {
set: function( elem, value ) { 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; var val = elem.value;
elem.setAttribute( "type", value ); elem.setAttribute( "type", value );
if ( val ) { if ( val ) {

View File

@ -1,9 +1,9 @@
define( [ define( [
"../core", "../core",
"../core/access", "../core/access",
"./support", "../var/isIE",
"../selector" "../selector"
], function( jQuery, access, support ) { ], function( jQuery, access, isIE ) {
"use strict"; "use strict";
@ -90,14 +90,11 @@ jQuery.extend( {
} ); } );
// Support: IE <=11+ // Support: IE <=11+
// Accessing the selectedIndex property // Accessing the selectedIndex property forces the browser to respect
// forces the browser to respect setting selected // setting selected on the option. The getter ensures a default option
// on the option // is selected when in an optgroup. ESLint rule "no-unused-expressions"
// The getter ensures a default option is selected // is disabled for this code since it considers such accessions noop.
// when in an optgroup if ( isIE ) {
// eslint rule "no-unused-expressions" is disabled for this code
// since it considers such accessions noop
if ( !support.optSelected ) {
jQuery.propHooks.selected = { jQuery.propHooks.selected = {
get: function( elem ) { get: function( elem ) {

View File

@ -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;
} );

View File

@ -2,6 +2,7 @@ define( [
"./core", "./core",
"./core/access", "./core/access",
"./var/rcssNum", "./var/rcssNum",
"./var/isIE",
"./css/var/rnumnonpx", "./css/var/rnumnonpx",
"./css/var/cssExpand", "./css/var/cssExpand",
"./css/isAutoPx", "./css/isAutoPx",
@ -10,14 +11,13 @@ define( [
"./css/var/swap", "./css/var/swap",
"./css/curCSS", "./css/curCSS",
"./css/adjustCSS", "./css/adjustCSS",
"./css/support",
"./css/finalPropName", "./css/finalPropName",
"./core/init", "./core/init",
"./core/ready", "./core/ready",
"./selector" // contains "./selector" // contains
], function( jQuery, access, rcssNum, rnumnonpx, cssExpand, isAutoPx, cssCamelCase, ], function( jQuery, access, rcssNum, isIE, rnumnonpx, cssExpand, isAutoPx,
getStyles, swap, curCSS, adjustCSS, support, finalPropName ) { cssCamelCase, getStyles, swap, curCSS, adjustCSS, finalPropName ) {
"use strict"; "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). // 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. // Fake content-box until we know it's needed to know the true value.
boxSizingNeeded = !support.boxSizingReliable() || extra, boxSizingNeeded = isIE || extra,
isBorderBox = boxSizingNeeded && isBorderBox = boxSizingNeeded &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box", jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
valueIsBorderBox = isBorderBox, valueIsBorderBox = isBorderBox,
@ -140,11 +140,12 @@ function getWidthOrHeight( elem, dimension, extra ) {
// Fall back to offsetWidth/offsetHeight when value is "auto" // Fall back to offsetWidth/offsetHeight when value is "auto"
// This happens for inline elements with no explicit setting (gh-3571) // This happens for inline elements with no explicit setting (gh-3571)
//
// Support: IE 9 - 11+ // Support: IE 9 - 11+
// Also use offsetWidth/offsetHeight for when box sizing is unreliable // Also use offsetWidth/offsetHeight for when box sizing is unreliable
// We use getClientRects() to check for hidden/disconnected. // We use getClientRects() to check for hidden/disconnected.
// In those cases, the computed value can be trusted to be border-box // 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 ) { elem.getClientRects().length ) {
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
@ -239,8 +240,9 @@ jQuery.extend( {
value += ret && ret[ 3 ] || ( isAutoPx( origName ) ? "px" : "" ); value += ret && ret[ 3 ] || ( isAutoPx( origName ) ? "px" : "" );
} }
// background-* props affect original clone's values // Support: IE <=9 - 11+
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { // background-* props of a cloned element affect the source element (#8908)
if ( isIE && value === "" && name.indexOf( "background" ) === 0 ) {
style[ name ] = "inherit"; style[ name ] = "inherit";
} }

View File

@ -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;
} );

View File

@ -2,6 +2,7 @@ define( [
"./core", "./core",
"./core/isAttached", "./core/isAttached",
"./var/concat", "./var/concat",
"./var/isIE",
"./var/push", "./var/push",
"./var/rcheckableType", "./var/rcheckableType",
"./core/access", "./core/access",
@ -11,7 +12,6 @@ define( [
"./manipulation/getAll", "./manipulation/getAll",
"./manipulation/setGlobalEval", "./manipulation/setGlobalEval",
"./manipulation/buildFragment", "./manipulation/buildFragment",
"./manipulation/support",
"./data/var/dataPriv", "./data/var/dataPriv",
"./data/var/dataUser", "./data/var/dataUser",
@ -23,9 +23,9 @@ define( [
"./traversing", "./traversing",
"./selector", "./selector",
"./event" "./event"
], function( jQuery, isAttached, concat, push, rcheckableType, ], function( jQuery, isAttached, concat, isIE, push,
access, rtagName, rscriptType, rcheckableType, access, rtagName, rscriptType,
wrapMap, getAll, setGlobalEval, buildFragment, support, wrapMap, getAll, setGlobalEval, buildFragment,
dataPriv, dataUser, acceptData, DOMEval, nodeName ) { dataPriv, dataUser, acceptData, DOMEval, nodeName ) {
"use strict"; "use strict";
@ -222,7 +222,7 @@ jQuery.extend( {
inPage = isAttached( elem ); inPage = isAttached( elem );
// Fix IE cloning issues // Fix IE cloning issues
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && if ( isIE && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
!jQuery.isXMLDoc( elem ) ) { !jQuery.isXMLDoc( elem ) ) {
// We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
@ -233,7 +233,7 @@ jQuery.extend( {
// Support: IE <=11+ // Support: IE <=11+
// IE fails to set the defaultValue to the correct value when // 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" ) { if ( destElements[ i ].nodeName.toLowerCase() === "textarea" ) {
destElements[ i ].defaultValue = srcElements[ i ].defaultValue; destElements[ i ].defaultValue = srcElements[ i ].defaultValue;
} }

View File

@ -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;
} );

7
src/var/isIE.js Normal file
View File

@ -0,0 +1,7 @@
define( [
"./document"
], function( document ) {
"use strict";
return document.documentMode;
} );

View File

@ -1 +1 @@
QUnit.assert.ok( !QUnit.moduleTypeSupported, "evaluated: inner nomodule script with src" ); QUnit.assert.ok( QUnit.isIE, "evaluated: inner nomodule script with src" );

View File

@ -1 +1 @@
QUnit.assert.ok( !QUnit.moduleTypeSupported, "evaluated: nomodule script with src" ); QUnit.assert.ok( QUnit.isIE, "evaluated: nomodule script with src" );

View File

@ -4,6 +4,9 @@
// jsdom implements a throwing `window.scrollTo`. // jsdom implements a throwing `window.scrollTo`.
QUnit.config.scrolltop = false; QUnit.config.scrolltop = false;
QUnit.isIE = false;
QUnit.testUnlessIE = QUnit.test;
const FILEPATH = "/test/data/testinit-jsdom.js"; const FILEPATH = "/test/data/testinit-jsdom.js";
const activeScript = document.currentScript; const activeScript = document.currentScript;
const parentUrl = activeScript && activeScript.src ? const parentUrl = activeScript && activeScript.src ?

View File

@ -256,14 +256,11 @@ if ( !window.__karma__ ) {
QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0; QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0;
QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic"; QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic";
// Async test for module script type support // Support: IE 11+
function moduleTypeSupported() { // A variable to make it easier to skip specific tests in IE, mostly
var script = document.createElement( "script" ); // testing integrations with newer Web features not supported by it.
script.type = "module"; QUnit.isIE = !!window.document.documentMode;
script.text = "QUnit.moduleTypeSupported = true"; QUnit.testUnlessIE = QUnit.isIE ? QUnit.skip : QUnit.test;
document.head.appendChild( script ).parentNode.removeChild( script );
}
moduleTypeSupported();
this.loadTests = function() { this.loadTests = function() {

View File

@ -138,7 +138,7 @@ var mocks = {
"constructor": "prototype collision (constructor)" "constructor": "prototype collision (constructor)"
} ); } );
req.query.keys.split( "|" ).forEach( function( key ) { req.query.keys.split( "|" ).forEach( function( key ) {
if ( req.headers[ key.toLowerCase() ] ) { if ( key.toLowerCase() in req.headers ) {
resp.write( key + ": " + req.headers[ key.toLowerCase() ] + "\n" ); resp.write( key + ": " + req.headers[ key.toLowerCase() ] + "\n" );
} }
} ); } );

View File

@ -260,7 +260,7 @@ QUnit.module( "ajax", {
} ); } );
}, },
url: url( "mock.php?action=headers&keys=siMPle|SometHing-elsE|OthEr|Nullable|undefined|Empty|ajax-send" ), url: url( "mock.php?action=headers&keys=siMPle|SometHing-elsE|OthEr|Nullable|undefined|Empty|ajax-send" ),
headers: { headers: supportjQuery.extend( {
"siMPle": "value", "siMPle": "value",
"SometHing-elsE": "other value", "SometHing-elsE": "other value",
"OthEr": "something else", "OthEr": "something else",
@ -268,11 +268,12 @@ QUnit.module( "ajax", {
"undefined": undefined "undefined": undefined
// Support: IE 9 - 11+, Edge 12 - 14 only // Support: IE 9 - 11+, Edge 12 - 14 only
// Not all browsers allow empty-string headers // IE can receive empty headers but not send them.
//"Empty": "" }, QUnit.isIE ? {} : {
}, "Empty": ""
} ),
success: function( data, _, xhr ) { success: function( data, _, xhr ) {
var i, emptyHeader, var i,
requestHeaders = jQuery.extend( this.headers, { requestHeaders = jQuery.extend( this.headers, {
"ajax-send": "test" "ajax-send": "test"
} ), } ),
@ -285,13 +286,7 @@ QUnit.module( "ajax", {
assert.strictEqual( data, tmp, "Headers were sent" ); assert.strictEqual( data, tmp, "Headers were sent" );
assert.strictEqual( xhr.getResponseHeader( "Sample-Header" ), "Hello World", "Sample header received" ); assert.strictEqual( xhr.getResponseHeader( "Sample-Header" ), "Hello World", "Sample header received" );
assert.ok( data.indexOf( "undefined" ) < 0, "Undefined header value was not sent" ); assert.ok( data.indexOf( "undefined" ) < 0, "Undefined header value was not sent" );
assert.strictEqual( xhr.getResponseHeader( "Empty-Header" ), "", "Empty header received" );
emptyHeader = xhr.getResponseHeader( "Empty-Header" );
if ( emptyHeader === null ) {
assert.ok( true, "Firefox doesn't support empty headers" );
} else {
assert.strictEqual( emptyHeader, "", "Empty header received" );
}
assert.strictEqual( xhr.getResponseHeader( "Sample-Header2" ), "Hello World 2", "Second sample header received" ); assert.strictEqual( xhr.getResponseHeader( "Sample-Header2" ), "Hello World 2", "Second sample header received" );
assert.strictEqual( xhr.getResponseHeader( "List-Header" ), "Item 1, Item 2", "List header received" ); assert.strictEqual( xhr.getResponseHeader( "List-Header" ), "Item 1, Item 2", "List header received" );
assert.strictEqual( xhr.getResponseHeader( "constructor" ), "prototype collision (constructor)", "constructor header received" ); assert.strictEqual( xhr.getResponseHeader( "constructor" ), "prototype collision (constructor)", "constructor header received" );

View File

@ -989,29 +989,37 @@ QUnit.test( "val() with non-matching values on dropdown list", function( assert
select6.remove(); select6.remove();
} ); } );
if ( "value" in document.createElement( "meter" ) && QUnit.test( "val() respects numbers without exception (Bug #9319) - progress",
"value" in document.createElement( "progress" ) ) { function( assert ) {
QUnit.test( "val() respects numbers without exception (Bug #9319)", function( assert ) { assert.expect( 2 );
assert.expect( 4 ); var $progress = jQuery( "<progress max='10' value='1.5'></progress>" );
var $meter = jQuery( "<meter min='0' max='10' value='5.6'></meter>" ),
$progress = jQuery( "<progress max='10' value='1.5'></progress>" );
try { try {
assert.equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" );
assert.equal( $meter.val(), $meter[ 0 ].value, "meter, api matches host and does not throw exception" );
assert.equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" ); assert.equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" );
assert.equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" ); assert.equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" );
} catch ( e ) {} } catch ( e ) {}
$meter.remove();
$progress.remove(); $progress.remove();
} ); } );
}
// IE doesn't support <meter>
QUnit.testUnlessIE( "val() respects numbers without exception (Bug #9319) - meter",
function( assert ) {
assert.expect( 2 );
var $meter = jQuery( "<meter min='0' max='10' value='5.6'></meter>" );
try {
assert.equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" );
assert.equal( $meter.val(), $meter[ 0 ].value, "meter, api matches host and does not throw exception" );
} catch ( e ) {}
$meter.remove();
} );
var testVal = function( valueObj, assert ) { var testVal = function( valueObj, assert ) {
assert.expect( 9 ); assert.expect( 9 );

View File

@ -329,7 +329,7 @@ QUnit.test( "isPlainObject", function( assert ) {
} }
} ); } );
QUnit[ typeof Symbol === "function" ? "test" : "skip" ]( "isPlainObject(Symbol)", function( assert ) { QUnit.testUnlessIE( "isPlainObject(Symbol)", function( assert ) {
assert.expect( 2 ); assert.expect( 2 );
assert.equal( jQuery.isPlainObject( Symbol() ), false, "Symbol" ); assert.equal( jQuery.isPlainObject( Symbol() ), false, "Symbol" );
@ -342,7 +342,7 @@ QUnit.test( "isPlainObject(localStorage)", function( assert ) {
assert.equal( jQuery.isPlainObject( localStorage ), false ); assert.equal( jQuery.isPlainObject( localStorage ), false );
} ); } );
QUnit[ "assign" in Object ? "test" : "skip" ]( "isPlainObject(Object.assign(...))", QUnit.testUnlessIE( "isPlainObject(Object.assign(...))",
function( assert ) { function( assert ) {
assert.expect( 1 ); assert.expect( 1 );

View File

@ -641,7 +641,11 @@ QUnit.test( "show/hide detached nodes", function( assert ) {
span.remove(); span.remove();
} ); } );
QUnit[ document.body.getRootNode ? "test" : "skip" ]( "show/hide shadow child nodes", function( assert ) { // Support: IE 11+, Edge 12 - 18+
// IE/Edge don't support Shadow DOM.
QUnit[ document.body.getRootNode ? "test" : "skip" ](
"show/hide shadow child nodes", function( assert ) {
assert.expect( 28 ); assert.expect( 28 );
jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" ); jQuery( "<div id='shadowHost'></div>" ).appendTo( "#qunit-fixture" );
var shadowHost = document.querySelector( "#shadowHost" ); var shadowHost = document.querySelector( "#shadowHost" );
@ -1210,11 +1214,10 @@ QUnit.test( "Do not append px (#9548, #12990, #2792)", function( assert ) {
} ); } );
QUnit[ // IE doesn't support the standard version of CSS Grid.
jQuery( "<div/>" )[ 0 ].style.gridArea === "" ? QUnit.testUnlessIE( "Do not append px to CSS Grid-related properties (gh-4007)",
"test" : function( assert ) {
"skip"
]( "Do not append px to CSS Grid-related properties (gh-4007)", function( assert ) {
assert.expect( 12 ); assert.expect( 12 );
var prop, value, subProp, subValue, $div, var prop, value, subProp, subValue, $div,
@ -1365,22 +1368,7 @@ testIframe(
} }
); );
( function() { QUnit.testUnlessIE( "css('width') and css('height') should return fractional values for nodes in the document", function( assert ) {
var supportsFractionalGBCR,
qunitFixture = document.getElementById( "qunit-fixture" ),
div = document.createElement( "div" );
div.style.width = "3.3px";
qunitFixture.appendChild( div );
supportsFractionalGBCR = div.getBoundingClientRect().width.toFixed( 1 ) === "3.3";
qunitFixture.removeChild( div );
QUnit.test( "css('width') and css('height') should return fractional values for nodes in the document", function( assert ) {
if ( !supportsFractionalGBCR ) {
assert.expect( 1 );
assert.ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
return;
}
assert.expect( 2 ); assert.expect( 2 );
var el = jQuery( "<div class='test-div'></div>" ).appendTo( "#qunit-fixture" ); var el = jQuery( "<div class='test-div'></div>" ).appendTo( "#qunit-fixture" );
@ -1390,15 +1378,9 @@ testIframe(
"css('width') should return fractional values" ); "css('width') should return fractional values" );
assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8", assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
"css('height') should return fractional values" ); "css('height') should return fractional values" );
} ); } );
QUnit.test( "css('width') and css('height') should return fractional values for disconnected nodes", function( assert ) {
if ( !supportsFractionalGBCR ) {
assert.expect( 1 );
assert.ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
return;
}
QUnit.testUnlessIE( "css('width') and css('height') should return fractional values for disconnected nodes", function( assert ) {
assert.expect( 2 ); assert.expect( 2 );
var el = jQuery( "<div style='width: 33.3px; height: 88.8px;'></div>" ); var el = jQuery( "<div style='width: 33.3px; height: 88.8px;'></div>" );
@ -1407,8 +1389,7 @@ testIframe(
"css('width') should return fractional values" ); "css('width') should return fractional values" );
assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8", assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
"css('height') should return fractional values" ); "css('height') should return fractional values" );
} ); } );
} )();
QUnit.test( "certain css values of 'normal' should be convertable to a number, see #8627", function( assert ) { QUnit.test( "certain css values of 'normal' should be convertable to a number, see #8627", function( assert ) {
assert.expect( 3 ); assert.expect( 3 );
@ -1736,16 +1717,9 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
} )(); } )();
( function() { // IE doesn't support CSS variables.
var supportsCssVars, QUnit.testUnlessIE( "css(--customProperty)", function( assert ) {
elem = jQuery( "<div>" ).appendTo( document.body ),
div = elem[ 0 ];
div.style.setProperty( "--prop", "value" );
supportsCssVars = !!getComputedStyle( div ).getPropertyValue( "--prop" );
elem.remove();
QUnit[ supportsCssVars ? "test" : "skip" ]( "css(--customProperty)", function( assert ) {
jQuery( "#qunit-fixture" ).append( jQuery( "#qunit-fixture" ).append(
"<style>\n" + "<style>\n" +
" .test__customProperties {\n" + " .test__customProperties {\n" +
@ -1802,9 +1776,11 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
assert.equal( $elem.css( "--prop4" ), "\"val4\"", "Works with double quotes" ); assert.equal( $elem.css( "--prop4" ), "\"val4\"", "Works with double quotes" );
assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" ); assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" );
} }
} ); } );
// IE doesn't support CSS variables.
QUnit.testUnlessIE( "Don't append px to CSS vars", function( assert ) {
QUnit[ supportsCssVars ? "test" : "skip" ]( "Don't append px to CSS vars", function( assert ) {
assert.expect( 3 ); assert.expect( 3 );
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ); var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
@ -1817,13 +1793,11 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
assert.equal( $div.css( "--a" ), "3", "--a: 3" ); assert.equal( $div.css( "--a" ), "3", "--a: 3" );
assert.equal( $div.css( "--line-height" ), "4", "--line-height: 4" ); assert.equal( $div.css( "--line-height" ), "4", "--line-height: 4" );
assert.equal( $div.css( "--lineHeight" ), "5", "--lineHeight: 5" ); assert.equal( $div.css( "--lineHeight" ), "5", "--lineHeight: 5" );
} ); } );
} )();
}
// Support: IE 11+ // Support: IE 11+
if ( document.documentMode ) { // This test requires Grid to be *not supported* to work.
if ( QUnit.isIE ) {
// Make sure explicitly provided IE vendor prefix (`-ms-`) is not converted // Make sure explicitly provided IE vendor prefix (`-ms-`) is not converted
// to a non-working `Ms` prefix in JavaScript. // to a non-working `Ms` prefix in JavaScript.
QUnit.test( "IE vendor prefixes are not mangled", function( assert ) { QUnit.test( "IE vendor prefixes are not mangled", function( assert ) {
@ -1836,3 +1810,5 @@ if ( document.documentMode ) {
assert.strictEqual( div.css( "-ms-grid-row" ), "1", "IE vendor prefixing" ); assert.strictEqual( div.css( "-ms-grid-row" ), "1", "IE vendor prefixing" );
} ); } );
} }
}

View File

@ -513,16 +513,14 @@ QUnit.test( ".removeData()", function( assert ) {
assert.equal( div.data( "test.foo" ), undefined, "Make sure data is intact" ); assert.equal( div.data( "test.foo" ), undefined, "Make sure data is intact" );
} ); } );
if ( window.JSON && window.JSON.stringify ) { QUnit.test( "JSON serialization (#8108)", function( assert ) {
QUnit.test( "JSON serialization (#8108)", function( assert ) {
assert.expect( 1 ); assert.expect( 1 );
var obj = { "foo": "bar" }; var obj = { "foo": "bar" };
jQuery.data( obj, "hidden", true ); jQuery.data( obj, "hidden", true );
assert.equal( JSON.stringify( obj ), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" ); assert.equal( JSON.stringify( obj ), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
} ); } );
}
QUnit.test( ".data should follow html5 specification regarding camel casing", function( assert ) { QUnit.test( ".data should follow html5 specification regarding camel casing", function( assert ) {
assert.expect( 12 ); assert.expect( 12 );

View File

@ -543,8 +543,7 @@ QUnit.test( "jQuery.Deferred.then - spec compatibility", function( assert ) {
} catch ( _ ) {} } catch ( _ ) {}
} ); } );
QUnit[ typeof Symbol === "function" && Symbol.toStringTag ? "test" : "skip" ]( QUnit.testUnlessIE( "jQuery.Deferred.then - IsCallable determination (gh-3596)",
"jQuery.Deferred.then - IsCallable determination (gh-3596)",
function( assert ) { function( assert ) {
assert.expect( 1 ); assert.expect( 1 );
@ -560,8 +559,7 @@ QUnit[ typeof Symbol === "function" && Symbol.toStringTag ? "test" : "skip" ](
defer.then( faker ).then( done ); defer.then( faker ).then( done );
defer.resolve(); defer.resolve();
} } );
);
QUnit.test( "jQuery.Deferred.exceptionHook", function( assert ) { QUnit.test( "jQuery.Deferred.exceptionHook", function( assert ) {

View File

@ -41,8 +41,7 @@ QUnit.test( "delegate/undelegate", function( assert ) {
.remove(); .remove();
} ); } );
if ( jQuery.fn.hover ) { QUnit[ jQuery.fn.hover ? "test" : "skip" ]( "hover() mouseenter mouseleave", function( assert ) {
QUnit.test( "hover() mouseenter mouseleave", function( assert ) {
assert.expect( 1 ); assert.expect( 1 );
var times = 0, var times = 0,
@ -60,10 +59,7 @@ if ( jQuery.fn.hover ) {
.mouseenter().mouseleave(); .mouseenter().mouseleave();
assert.equal( times, 4, "hover handlers fired" ); assert.equal( times, 4, "hover handlers fired" );
} );
} );
}
QUnit[ jQuery.fn.click ? "test" : "skip" ]( "trigger() shortcuts", function( assert ) { QUnit[ jQuery.fn.click ? "test" : "skip" ]( "trigger() shortcuts", function( assert ) {
assert.expect( 5 ); assert.expect( 5 );

View File

@ -659,9 +659,9 @@ QUnit.test( "interaction with scrollbars (gh-3589)", function( assert ) {
parent = jQuery( "<div/>" ) parent = jQuery( "<div/>" )
.css( { position: "absolute", width: "1000px", height: "1000px" } ) .css( { position: "absolute", width: "1000px", height: "1000px" } )
.appendTo( "#qunit-fixture" ), .appendTo( "#qunit-fixture" ),
fraction = jQuery.support.boxSizingReliable() ?
jQuery( "<div style='width:4.5px;'/>" ).appendTo( parent ).width() % 1 : // Workarounds for IE kill fractional output here.
0, fraction = document.documentMode ? 0 : 0.5,
borderWidth = 1, borderWidth = 1,
padding = 2, padding = 2,
size = 100 + fraction, size = 100 + fraction,

View File

@ -221,6 +221,8 @@ supportjQuery.each( hideOptions, function( type, setup ) {
assert.expectJqData( this, $span, "olddisplay" ); assert.expectJqData( this, $span, "olddisplay" );
} ); } );
// Support: IE 11+, Edge 12 - 18+
// IE/Edge don't support Shadow DOM.
QUnit[ document.body.getRootNode ? "test" : "skip" ]( QUnit[ document.body.getRootNode ? "test" : "skip" ](
"Persist correct display value - " + type + " hidden, shadow child", function( assert ) { "Persist correct display value - " + type + " hidden, shadow child", function( assert ) {
assert.expect( 3 ); assert.expect( 3 );

View File

@ -445,8 +445,7 @@ QUnit.test( "append HTML5 sectioning elements (Bug #6485)", function( assert ) {
assert.equal( aside.length, 1, "HTML5 elements do not collapse their children" ); assert.equal( aside.length, 1, "HTML5 elements do not collapse their children" );
} ); } );
if ( jQuery.css ) { QUnit[ jQuery.fn.css ? "test" : "skip" ]( "HTML5 Elements inherit styles from style rules (Bug #10501)", function( assert ) {
QUnit.test( "HTML5 Elements inherit styles from style rules (Bug #10501)", function( assert ) {
assert.expect( 1 ); assert.expect( 1 );
@ -455,8 +454,7 @@ if ( jQuery.css ) {
// In IE, the missing background color will claim its value is "transparent" // In IE, the missing background color will claim its value is "transparent"
assert.notEqual( jQuery( "section" ).css( "background-color" ), "transparent", "HTML5 elements inherit styles" ); assert.notEqual( jQuery( "section" ).css( "background-color" ), "transparent", "HTML5 elements inherit styles" );
} ); } );
}
QUnit.test( "html(String) with HTML5 (Bug #6485)", function( assert ) { QUnit.test( "html(String) with HTML5 (Bug #6485)", function( assert ) {
@ -1767,9 +1765,9 @@ QUnit.test( "html(Function)", function( assert ) {
QUnit[ QUnit[
// Support: Edge 16 - 18+ // Support: Edge 16 - 18+
// Edge sometimes doesn't execute module scripts so skip the test there. // Edge sometimes doesn't execute module scripts so skip the test there.
( QUnit.moduleTypeSupported && !/edge\//i.test( navigator.userAgent ) ) ? ( QUnit.isIE || /edge\//i.test( navigator.userAgent ) ) ?
"test" : "skip" :
"skip" "test"
]( "html(script type module)", function( assert ) { ]( "html(script type module)", function( assert ) {
assert.expect( 4 ); assert.expect( 4 );
var done = assert.async(), var done = assert.async(),
@ -1794,18 +1792,17 @@ QUnit[
QUnit.test( "html(script nomodule)", function( assert ) { QUnit.test( "html(script nomodule)", function( assert ) {
// Support: IE 9 - 11+
// `nomodule` scripts should be executed by legacy browsers only. // `nomodule` scripts should be executed by legacy browsers only.
assert.expect( QUnit.moduleTypeSupported ? 0 : 4 ); assert.expect( QUnit.isIE ? 4 : 0 );
var done = assert.async(), var done = assert.async(),
$fixture = jQuery( "#qunit-fixture" ); $fixture = jQuery( "#qunit-fixture" );
$fixture.html( $fixture.html(
[ [
"<script nomodule>QUnit.assert.ok( !QUnit.moduleTypeSupported, 'evaluated: nomodule script' );</script>", "<script nomodule>QUnit.assert.ok( QUnit.isIE, 'evaluated: nomodule script' );</script>",
"<script nomodule src='" + url( "nomodule.js" ) + "'></script>", "<script nomodule src='" + url( "nomodule.js" ) + "'></script>",
"<div>", "<div>",
"<script nomodule>QUnit.assert.ok( !QUnit.moduleTypeSupported, 'evaluated: inner nomodule script' );</script>", "<script nomodule>QUnit.assert.ok( QUnit.isIE, 'evaluated: inner nomodule script' );</script>",
"<script nomodule src='" + url( "inner_nomodule.js" ) + "'></script>", "<script nomodule src='" + url( "inner_nomodule.js" ) + "'></script>",
"</div>" "</div>"
].join( "" ) ].join( "" )

View File

@ -271,8 +271,7 @@ QUnit.test( ".promise(obj)", function( assert ) {
assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" ); assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" );
} ); } );
if ( jQuery.fn.stop ) { QUnit[ jQuery.fn.stop ? "test" : "skip" ]( "delay() can be stopped", function( assert ) {
QUnit.test( "delay() can be stopped", function( assert ) {
var done = assert.async(); var done = assert.async();
assert.expect( 3 ); assert.expect( 3 );
var storage = {}; var storage = {};
@ -307,9 +306,9 @@ if ( jQuery.fn.stop ) {
setTimeout( function() { setTimeout( function() {
done(); done();
}, 1500 ); }, 1500 );
} ); } );
QUnit.test( "queue stop hooks", function( assert ) { QUnit[ jQuery.fn.stop ? "test" : "skip" ]( "queue stop hooks", function( assert ) {
assert.expect( 2 ); assert.expect( 2 );
var done = assert.async(); var done = assert.async();
var foo = jQuery( "#foo" ); var foo = jQuery( "#foo" );
@ -329,6 +328,4 @@ if ( jQuery.fn.stop ) {
} ); } );
foo.stop( false, true ); foo.stop( false, true );
} ); } );
} // if ( jQuery.fn.stop )

View File

@ -58,48 +58,12 @@ testIframe(
var expected, var expected,
userAgent = window.navigator.userAgent, userAgent = window.navigator.userAgent,
expectedMap = { expectedMap = {
edge: { edge: {},
boxSizingReliable: true, ie_11: {},
clearCloneStyle: true, chrome: {},
noCloneChecked: true, safari: {},
optSelected: true, firefox: {},
radioValue: true ios: {}
},
ie_11: {
boxSizingReliable: false,
clearCloneStyle: false,
noCloneChecked: false,
optSelected: false,
radioValue: false
},
chrome: {
boxSizingReliable: true,
clearCloneStyle: true,
noCloneChecked: true,
optSelected: true,
radioValue: true
},
safari: {
boxSizingReliable: true,
clearCloneStyle: true,
noCloneChecked: true,
optSelected: true,
radioValue: true
},
firefox: {
boxSizingReliable: true,
clearCloneStyle: true,
noCloneChecked: true,
optSelected: true,
radioValue: true
},
ios: {
boxSizingReliable: true,
clearCloneStyle: true,
noCloneChecked: true,
optSelected: true,
radioValue: true
}
}; };
if ( /edge\//i.test( userAgent ) ) { if ( /edge\//i.test( userAgent ) ) {
@ -140,8 +104,8 @@ testIframe(
} }
} ); } );
QUnit.test( "Verify most support tests are failing in one " + QUnit.test( "Verify support tests are failing in one of tested browsers",
"of tested browsers", function( assert ) { function( assert ) {
var prop, browserKey, supportTestName, var prop, browserKey, supportTestName,
i = 0, i = 0,

View File

@ -773,7 +773,7 @@ QUnit.test( "contents() for <template />", function( assert ) {
assert.equal( contents.filter( "div" ).length, 3, "Count cloned elements from template" ); assert.equal( contents.filter( "div" ).length, 3, "Count cloned elements from template" );
} ); } );
QUnit[ "content" in document.createElement( "template" ) ? "test" : "skip" ]( "contents() for <template /> remains inert", function( assert ) { QUnit.testUnlessIE( "contents() for <template /> remains inert", function( assert ) {
assert.expect( 2 ); assert.expect( 2 );
Globals.register( "testScript" ); Globals.register( "testScript" );