From 622db29d9c1aed1e51586db72861a1aab4d7606f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82=C4=99biowski?= Date: Wed, 23 Mar 2016 14:16:38 +0100 Subject: [PATCH] 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 90d7cc1d8b2ea7ac75f0eacb42439349c9c73278 --- src/attributes/val.js | 1 + test/data/css/cssWidthBeforeDocReady.html | 1 - test/unit/css.js | 38 ++++++++--------- test/unit/effects.js | 50 +++++++++-------------- test/unit/event.js | 1 + test/unit/wrap.js | 2 +- 6 files changed, 38 insertions(+), 55 deletions(-) diff --git a/src/attributes/val.js b/src/attributes/val.js index a8a2e12fb..1338fcdf6 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -108,6 +108,7 @@ jQuery.extend( { for ( ; i < max; i++ ) { option = options[ i ]; + // Support: IE <=9 only // IE8-9 doesn't update selected after form reset (#2551) if ( ( option.selected || i === index ) && diff --git a/test/data/css/cssWidthBeforeDocReady.html b/test/data/css/cssWidthBeforeDocReady.html index 12e954dc0..a8fa4af0f 100644 --- a/test/data/css/cssWidthBeforeDocReady.html +++ b/test/data/css/cssWidthBeforeDocReady.html @@ -4,7 +4,6 @@ " ).appendTo( fixture ); + jQuery( "" ).appendTo( fixture ); - el = jQuery( "
" ).appendTo( fixture ); + el = jQuery( "
" ).appendTo( fixture ); - assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (filter:alpha with spaces)" ); - el.removeClass( "opacityWithSpaces_t12685" ).addClass( "opacityNoSpaces_t12685" ); - assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (filter:alpha without spaces)" ); + assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet" ); el.css( "opacity", 0.3 ); assert.equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override 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 ) { diff --git a/test/unit/effects.js b/test/unit/effects.js index 2f0ac9334..653db6431 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -50,7 +50,7 @@ QUnit.test( "show() basic", function( assert ) { QUnit.test( "show()", function( assert ) { assert.expect( 27 ); - var div, speeds, old, test, + var div, speeds, test, hiddendiv = jQuery( "div.hidden" ); assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); @@ -99,13 +99,9 @@ QUnit.test( "show()", function( assert ) { "
" + "

" + "
" + - "
" + - "
" + "" ).appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" ); - old = jQuery( "#test-table" ).show().css( "display" ) !== "table"; - jQuery( "#test-table" ).remove(); - test = { "div": "block", "p": "block", @@ -113,14 +109,14 @@ QUnit.test( "show()", function( assert ) { "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 ) { @@ -144,34 +140,28 @@ supportjQuery.each( hideOptions, function( type, 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 // because we're showing width/height // Can't animate width/height inline // See #14344 - test = { + var test = { "div": "block", "p": "block", "a": "inline", "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 ) { @@ -369,10 +359,8 @@ QUnit.test( "animate block width/height", function( assert ) { QUnit.test( "animate table width/height", function( assert ) { assert.expect( 1 ); - var displayMode = jQuery( "#table" ).css( "display" ) !== "table" ? "block" : "table"; - 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 ); } ); diff --git a/test/unit/event.js b/test/unit/event.js index 63b367ea8..33393c835 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2920,6 +2920,7 @@ if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) { $text = jQuery( "#text1" ), $radio = jQuery( "#radio1" ).trigger( "focus" ); + // Support: IE <=10 only // IE8-10 fire focus/blur events asynchronously; this is the resulting mess. // IE's browser window must be topmost for this to work properly!! QUnit.stop(); diff --git a/test/unit/wrap.js b/test/unit/wrap.js index 80abd9e87..02994bafa 100644 --- a/test/unit/wrap.js +++ b/test/unit/wrap.js @@ -60,7 +60,7 @@ function testWrap( val, assert ) { j.wrap( val( "" ) ); assert.equal( - jQuery( "#nonnodes > i" ).length, jQuery( "#nonnodes" )[ 0 ].childNodes.length, + jQuery( "#nonnodes > i" ).length, 3, "Check node,textnode,comment wraps ok" ); assert.equal( -- 2.39.5