Docs:Tests: Remove legacy code & add support comments where needed

This commits backports some changes done in the patch to the then-existing
compat branch that removed support for old browsers and added some support
comments.

Refs 90d7cc1d8b
This commit is contained in:
Michał Gołębiowski 2016-03-23 14:16:38 +01:00
parent 44cb97e0cf
commit 622db29d9c
6 changed files with 38 additions and 55 deletions

View File

@ -108,6 +108,7 @@ jQuery.extend( {
for ( ; i < max; i++ ) { for ( ; i < max; i++ ) {
option = options[ i ]; option = options[ i ];
// Support: IE <=9 only
// IE8-9 doesn't update selected after form reset (#2551) // IE8-9 doesn't update selected after form reset (#2551)
if ( ( option.selected || i === index ) && if ( ( option.selected || i === index ) &&

View File

@ -4,7 +4,6 @@
<meta charset="utf-8"> <meta charset="utf-8">
<style> <style>
#test { #test {
-webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
width: 100px; width: 100px;
height: 100px; height: 100px;

View File

@ -58,9 +58,9 @@ QUnit.test( "css(String|Hash)", function( assert ) {
jQuery( "#foo" ).css( { "opacity": "" } ); jQuery( "#foo" ).css( { "opacity": "" } );
assert.equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when set to an empty String" ); assert.equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when set to an empty String" );
assert.equal( jQuery( "#empty" ).css( "opacity" ), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" ); assert.equal( jQuery( "#empty" ).css( "opacity" ), "0", "Assert opacity is accessible" );
jQuery( "#empty" ).css( { "opacity": "1" } ); jQuery( "#empty" ).css( { "opacity": "1" } );
assert.equal( jQuery( "#empty" ).css( "opacity" ), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" ); assert.equal( jQuery( "#empty" ).css( "opacity" ), "1", "Assert opacity is taken from style attribute when set" );
div = jQuery( "#nothiddendiv" ); div = jQuery( "#nothiddendiv" );
child = jQuery( "#nothiddendivchild" ); child = jQuery( "#nothiddendivchild" );
@ -478,7 +478,7 @@ QUnit.test( "show()", function( assert ) {
assert.expect( 18 ); assert.expect( 18 );
var hiddendiv, div, pass, old, test; var hiddendiv, div, pass, test;
hiddendiv = jQuery( "div.hidden" ); hiddendiv = jQuery( "div.hidden" );
assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" );
@ -504,13 +504,9 @@ QUnit.test( "show()", function( assert ) {
"<div id='show-tests'>" + "<div id='show-tests'>" +
"<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>" + "<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>" +
"<table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table>" + "<table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table>" +
"<ul><li></li></ul></div>" + "<ul><li></li></ul></div>"
"<table id='test-table'></table>"
).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" ); ).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );
old = jQuery( "#test-table" ).show().css( "display" ) !== "table";
jQuery( "#test-table" ).remove();
test = { test = {
"div": "block", "div": "block",
"p": "block", "p": "block",
@ -518,14 +514,14 @@ QUnit.test( "show()", function( assert ) {
"code": "inline", "code": "inline",
"pre": "block", "pre": "block",
"span": "inline", "span": "inline",
"table": old ? "block" : "table", "table": "table",
"thead": old ? "block" : "table-header-group", "thead": "table-header-group",
"tbody": old ? "block" : "table-row-group", "tbody": "table-row-group",
"tr": old ? "block" : "table-row", "tr": "table-row",
"th": old ? "block" : "table-cell", "th": "table-cell",
"td": old ? "block" : "table-cell", "td": "table-cell",
"ul": "block", "ul": "block",
"li": old ? "block" : "list-item" "li": "list-item"
}; };
jQuery.each( test, function( selector, expected ) { jQuery.each( test, function( selector, expected ) {
@ -1234,23 +1230,21 @@ QUnit.test( "cssHooks - expand", function( assert ) {
} ); } );
QUnit.test( "css opacity consistency across browsers (#12685)", function( assert ) { QUnit.test( "css opacity consistency across browsers (#12685)", function( assert ) {
assert.expect( 4 ); assert.expect( 3 );
var el, var el,
fixture = jQuery( "#qunit-fixture" ); fixture = jQuery( "#qunit-fixture" );
// Append style element // Append style element
jQuery( "<style>.opacityWithSpaces_t12685 { opacity: 0.1; filter: alpha(opacity = 10); } .opacityNoSpaces_t12685 { opacity: 0.2; filter: alpha(opacity=20); }</style>" ).appendTo( fixture ); jQuery( "<style>.opacity_t12685 { opacity: 0.1; }</style>" ).appendTo( fixture );
el = jQuery( "<div class='opacityWithSpaces_t12685'></div>" ).appendTo( fixture ); el = jQuery( "<div class='opacity_t12685'></div>" ).appendTo( fixture );
assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (filter:alpha with spaces)" ); assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet" );
el.removeClass( "opacityWithSpaces_t12685" ).addClass( "opacityNoSpaces_t12685" );
assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (filter:alpha without spaces)" );
el.css( "opacity", 0.3 ); el.css( "opacity", 0.3 );
assert.equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" ); assert.equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" );
el.css( "opacity", "" ); el.css( "opacity", "" );
assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "remove opacity override" ); assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "remove opacity override" );
} ); } );
QUnit[ jQuery.find.compile ? "test" : "skip" ]( ":visible/:hidden selectors", function( assert ) { QUnit[ jQuery.find.compile ? "test" : "skip" ]( ":visible/:hidden selectors", function( assert ) {

50
test/unit/effects.js vendored
View File

@ -50,7 +50,7 @@ QUnit.test( "show() basic", function( assert ) {
QUnit.test( "show()", function( assert ) { QUnit.test( "show()", function( assert ) {
assert.expect( 27 ); assert.expect( 27 );
var div, speeds, old, test, var div, speeds, test,
hiddendiv = jQuery( "div.hidden" ); hiddendiv = jQuery( "div.hidden" );
assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" );
@ -99,13 +99,9 @@ QUnit.test( "show()", function( assert ) {
"<div id='show-tests'>" + "<div id='show-tests'>" +
"<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>" + "<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>" +
"<table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table>" + "<table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table>" +
"<ul><li></li></ul></div>" + "<ul><li></li></ul></div>"
"<table id='test-table'></table>"
).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" ); ).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );
old = jQuery( "#test-table" ).show().css( "display" ) !== "table";
jQuery( "#test-table" ).remove();
test = { test = {
"div": "block", "div": "block",
"p": "block", "p": "block",
@ -113,14 +109,14 @@ QUnit.test( "show()", function( assert ) {
"code": "inline", "code": "inline",
"pre": "block", "pre": "block",
"span": "inline", "span": "inline",
"table": old ? "block" : "table", "table": "table",
"thead": old ? "block" : "table-header-group", "thead": "table-header-group",
"tbody": old ? "block" : "table-row-group", "tbody": "table-row-group",
"tr": old ? "block" : "table-row", "tr": "table-row",
"th": old ? "block" : "table-cell", "th": "table-cell",
"td": old ? "block" : "table-cell", "td": "table-cell",
"ul": "block", "ul": "block",
"li": old ? "block" : "list-item" "li": "list-item"
}; };
jQuery.each( test, function( selector, expected ) { jQuery.each( test, function( selector, expected ) {
@ -144,34 +140,28 @@ supportjQuery.each( hideOptions, function( type, setup ) {
"<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>" + "<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>" +
"<table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody>" + "<table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody>" +
"</table>" + "</table>" +
"<ul><li></li></ul></div>" + "<ul><li></li></ul></div>"
"<table id='test-table'></table>"
).appendTo( "#qunit-fixture" ).find( "*" ).each( setup ); ).appendTo( "#qunit-fixture" ).find( "*" ).each( setup );
var test,
old = jQuery( "#test-table" ).show().css( "display" ) !== "table";
jQuery( "#test-table" ).remove();
// Note: inline elements are expected to be inline-block // Note: inline elements are expected to be inline-block
// because we're showing width/height // because we're showing width/height
// Can't animate width/height inline // Can't animate width/height inline
// See #14344 // See #14344
test = { var test = {
"div": "block", "div": "block",
"p": "block", "p": "block",
"a": "inline", "a": "inline",
"code": "inline", "code": "inline",
"pre": "block", "pre": "block",
"span": "inline", "span": "inline",
"table": old ? "block" : "table", "table": "table",
"thead": old ? "block" : "table-header-group", "thead": "table-header-group",
"tbody": old ? "block" : "table-row-group", "tbody": "table-row-group",
"tr": old ? "block" : "table-row", "tr": "table-row",
"th": old ? "block" : "table-cell", "th": "table-cell",
"td": old ? "block" : "table-cell", "td": "table-cell",
"ul": "block", "ul": "block",
"li": old ? "block" : "list-item" "li": "list-item"
}; };
jQuery.each( test, function( selector ) { jQuery.each( test, function( selector ) {
@ -369,10 +359,8 @@ QUnit.test( "animate block width/height", function( assert ) {
QUnit.test( "animate table width/height", function( assert ) { QUnit.test( "animate table width/height", function( assert ) {
assert.expect( 1 ); assert.expect( 1 );
var displayMode = jQuery( "#table" ).css( "display" ) !== "table" ? "block" : "table";
jQuery( "#table" ).animate( { width: 42, height: 42 }, 100, function() { jQuery( "#table" ).animate( { width: 42, height: 42 }, 100, function() {
assert.equal( jQuery( this ).css( "display" ), displayMode, "display mode is correct" ); assert.equal( jQuery( this ).css( "display" ), "table", "display mode is correct" );
} ); } );
this.clock.tick( 100 ); this.clock.tick( 100 );
} ); } );

View File

@ -2920,6 +2920,7 @@ if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) {
$text = jQuery( "#text1" ), $text = jQuery( "#text1" ),
$radio = jQuery( "#radio1" ).trigger( "focus" ); $radio = jQuery( "#radio1" ).trigger( "focus" );
// Support: IE <=10 only
// IE8-10 fire focus/blur events asynchronously; this is the resulting mess. // IE8-10 fire focus/blur events asynchronously; this is the resulting mess.
// IE's browser window must be topmost for this to work properly!! // IE's browser window must be topmost for this to work properly!!
QUnit.stop(); QUnit.stop();

View File

@ -60,7 +60,7 @@ function testWrap( val, assert ) {
j.wrap( val( "<i></i>" ) ); j.wrap( val( "<i></i>" ) );
assert.equal( assert.equal(
jQuery( "#nonnodes > i" ).length, jQuery( "#nonnodes" )[ 0 ].childNodes.length, jQuery( "#nonnodes > i" ).length, 3,
"Check node,textnode,comment wraps ok" "Check node,textnode,comment wraps ok"
); );
assert.equal( assert.equal(