From 65d71843b7c37dbdba2cfcb1bc7055cb522c5af6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82=C4=99biowski?= Date: Mon, 16 Nov 2015 21:25:05 +0100 Subject: [PATCH] Revert "Misc: Drop support for older browsers; update support comments" This reverts commit 740e190223d19a114d5373758127285d14d6b71e. --- src/attributes/support.js | 2 +- src/core.js | 4 +--- src/core/init.js | 4 +++- src/css.js | 2 +- src/css/curCSS.js | 11 +++++----- src/css/hiddenVisibleSelectors.js | 7 ++++++- src/css/support.js | 10 +++++---- src/event.js | 8 ++++++- src/manipulation.js | 4 ++-- src/manipulation/support.js | 4 ++-- src/offset.js | 6 +++++- test/unit/css.js | 9 +++++--- test/unit/dimensions.js | 5 +++-- test/unit/event.js | 15 ++++++++----- test/unit/support.js | 35 ++++++++++++++++++++++++++++++- 15 files changed, 93 insertions(+), 33 deletions(-) diff --git a/src/attributes/support.js b/src/attributes/support.js index f93ba0181..5b8118bb5 100644 --- a/src/attributes/support.js +++ b/src/attributes/support.js @@ -10,7 +10,7 @@ define( [ input.type = "checkbox"; - // Support: Android<4.4 + // Support: iOS<=5.1, Android<=4.2+ // Default value for a checkbox should be "on" support.checkOn = input.value !== ""; diff --git a/src/core.js b/src/core.js index ab172bb4f..e8f0d9d37 100644 --- a/src/core.js +++ b/src/core.js @@ -255,7 +255,7 @@ jQuery.extend( { return obj + ""; } - // Support: Android<4.0 (functionish RegExp) + // Support: Android<4.0, iOS<6 (functionish RegExp) return typeof obj === "object" || typeof obj === "function" ? class2type[ toString.call( obj ) ] || "object" : typeof obj; @@ -348,8 +348,6 @@ jQuery.extend( { return arr == null ? -1 : indexOf.call( arr, elem, i ); }, - // Support: Android<4.1, PhantomJS<2 - // push.apply(_, arraylike) throws on ancient WebKit merge: function( first, second ) { var len = +second.length, j = 0, diff --git a/src/core/init.js b/src/core/init.js index 7748c38fb..c2b6c94d7 100644 --- a/src/core/init.js +++ b/src/core/init.js @@ -75,7 +75,9 @@ var rootjQuery, } else { elem = document.getElementById( match[ 2 ] ); - if ( elem ) { + // Support: Blackberry 4.6 + // gEBID returns nodes no longer in the document (#6963) + if ( elem && elem.parentNode ) { // Inject the element directly into the jQuery object this.length = 1; diff --git a/src/css.js b/src/css.js index 7bff81440..0aa9d0e9c 100644 --- a/src/css.js +++ b/src/css.js @@ -36,7 +36,7 @@ var fontWeight: "400" }, - cssPrefixes = [ "Webkit", "Moz", "ms" ], + cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], emptyStyle = document.createElement( "div" ).style; // Return a css property mapped to a potentially vendor prefixed property diff --git a/src/css/curCSS.js b/src/css/curCSS.js index be643ab54..d95e287cf 100644 --- a/src/css/curCSS.js +++ b/src/css/curCSS.js @@ -5,7 +5,7 @@ define( [ "./var/getStyles", "./support", "../selector" // Get jQuery.contains -], function( jQuery, rnumnonpx, rmargin, getStyles, support ) { +], function( jQuery, rnumnonpx, rmargin, getStyles ) { function curCSS( elem, name, computed ) { var width, minWidth, maxWidth, ret, @@ -22,12 +22,13 @@ function curCSS( elem, name, computed ) { ret = jQuery.style( elem, name ); } + // Support: iOS < 6, Android 4.0-4.3 only // A tribute to the "awesome hack by Dean Edwards" - // Android Browser returns percentage for some values, - // but width seems to be reliably pixels. - // This is against the CSSOM draft spec: + // iOS < 6 (at least) returns percentage for a larger set of values, + // but width seems to be reliably pixels + // this is against the CSSOM draft spec: // http://dev.w3.org/csswg/cssom/#resolved-values - if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { + if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { // Remember the original values width = style.width; diff --git a/src/css/hiddenVisibleSelectors.js b/src/css/hiddenVisibleSelectors.js index 9a8a28cf8..0d05be97e 100644 --- a/src/css/hiddenVisibleSelectors.js +++ b/src/css/hiddenVisibleSelectors.js @@ -4,7 +4,12 @@ define( [ ], function( jQuery ) { jQuery.expr.filters.hidden = function( elem ) { - return !jQuery.expr.filters.visible( 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; }; jQuery.expr.filters.visible = function( elem ) { return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); diff --git a/src/css/support.js b/src/css/support.js index f8e02d048..54d0d9c70 100644 --- a/src/css/support.js +++ b/src/css/support.js @@ -29,10 +29,12 @@ define( [ // so they're executed at the same time to save the second computation. function computeStyleTests() { div.style.cssText = - "box-sizing:border-box;" + - "position:relative;display:block;" + - "margin:auto;border:1px;padding:1px;" + - "top:1%;width:50%"; + + // Support: Firefox<29, 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%;" + + "border:1px;padding:1px;width:4px;position:absolute"; div.innerHTML = ""; documentElement.appendChild( container ); diff --git a/src/event.js b/src/event.js index 280581249..e9d1053dc 100644 --- a/src/event.js +++ b/src/event.js @@ -469,7 +469,13 @@ jQuery.event = { event[ prop ] = originalEvent[ prop ]; } - // Support: Safari 6-8+ + // Support: Cordova 2.5 (WebKit) (#13255) + // All events should have a target; Cordova deviceready doesn't + if ( !event.target ) { + event.target = document; + } + + // Support: Safari 6.0+, Chrome<28 // Target should not be a text node (#504, #13143) if ( event.target.nodeType === 3 ) { event.target = event.target.parentNode; diff --git a/src/manipulation.js b/src/manipulation.js index ceb970cbd..046424a78 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -464,8 +464,8 @@ jQuery.each( { elems = i === last ? this : this.clone( true ); jQuery( insert[ i ] )[ original ]( elems ); - // Support: Android<4.1, PhantomJS<2 - // .get() because push.apply(_, arraylike) throws on ancient WebKit + // Support: QtWebKit + // .get() because push.apply(_, arraylike) throws push.apply( ret, elems.get() ); } diff --git a/src/manipulation/support.js b/src/manipulation/support.js index 4f6b9de87..cd4081ebb 100644 --- a/src/manipulation/support.js +++ b/src/manipulation/support.js @@ -8,7 +8,7 @@ define( [ div = fragment.appendChild( document.createElement( "div" ) ), input = document.createElement( "input" ); - // Support: Android 4.0-4.3 + // Support: Android 4.0-4.3, Safari<=5.1 // Check state lost if the name is set (#11217) // Support: Windows Web Apps (WWA) // `name` and `type` must use .setAttribute for WWA (#14901) @@ -18,7 +18,7 @@ define( [ div.appendChild( input ); - // Support: Android<4.2 + // Support: Safari<=5.1, Android<4.2 // Older WebKit doesn't clone checked state correctly in fragments support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; diff --git a/src/offset.js b/src/offset.js index 4352a9995..ae9ccc119 100644 --- a/src/offset.js +++ b/src/offset.js @@ -98,7 +98,11 @@ jQuery.fn.extend( { return box; } - box = elem.getBoundingClientRect(); + // Support: BlackBerry 5, iOS 3 (original iPhone) + // If we don't have gBCR, just use 0,0 rather than error + if ( elem.getBoundingClientRect ) { + box = elem.getBoundingClientRect(); + } win = getWindow( doc ); return { top: box.top + win.pageYOffset - docElem.clientTop, diff --git a/test/unit/css.js b/test/unit/css.js index 7aa87d85f..09db05729 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -293,6 +293,9 @@ QUnit.test( "css(String, Object)", function( assert ) { j = jQuery( "#nonnodes" ).contents(); j.css( "overflow", "visible" ); assert.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; assert.equal( jQuery( "#t2037 .hidden" ).css( "display" ), "none", "Make sure browser thinks it is hidden" ); div = jQuery( "#nothiddendiv" ); @@ -867,9 +870,9 @@ QUnit.test( "Do not append px (#9548, #12990)", function( assert ) { QUnit.test( "css('width') and css('height') should respect box-sizing, see #11004", function( assert ) { assert.expect( 4 ); - // Support: Android 2.3 (-webkit-box-sizing). - var el_dis = jQuery( "
test
" ), - el = el_dis.clone().appendTo( "#qunit-fixture" ); + // Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions). + var el_dis = jQuery("
test
"), + el = el_dis.clone().appendTo("#qunit-fixture"); assert.equal( el.css( "width" ), el.css( "width", el.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing, see #11004" ); assert.equal( el_dis.css( "width" ), el_dis.css( "width", el_dis.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing for disconnected element, see #11004" ); diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 5bd4f3384..9ffc6083c 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -409,9 +409,10 @@ QUnit.test( "getters on non elements should return null", function( assert ) { QUnit.test( "setters with and without box-sizing:border-box", function( assert ) { assert.expect( 60 ); + // Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions). var parent = jQuery( "#foo" ).css( { width: "200px", height: "200px", "font-size": "16px" } ), - el_bb = jQuery( "
" ).appendTo( parent ), - el = jQuery( "
" ).appendTo( parent ); + el_bb = jQuery( "
test
" ).appendTo( parent ), + el = jQuery( "
test
" ).appendTo( parent ); jQuery.each( { "number": { set: 100, expected: 100 }, diff --git a/test/unit/event.js b/test/unit/event.js index 12f132e0d..804ece2ca 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1416,7 +1416,7 @@ QUnit.test( "Submit event can be stopped (#11049)", function( assert ) { form.remove(); } ); -// Test beforeunload event only if it supported. +// Test beforeunload event only if it supported (i.e. not Opera) // 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. @@ -2520,14 +2520,15 @@ testIframeWithCallback( var input = jQuery( frameDoc ).find( "#frame-input" ); + if ( input.length ) { // Create a focusin handler on the parent; shouldn't affect the iframe's fate - jQuery( "body" ).on( "focusin.iframeTest", function() { + jQuery ( "body" ).on( "focusin.iframeTest", function() { assert.ok( false, "fired a focusin event in the parent document" ); - } ); + }); input.on( "focusin", function() { assert.ok( true, "fired a focusin event in the iframe" ); - } ); + }); // Avoid a native event; Chrome can't force focus to another frame input.trigger( "focusin" ); @@ -2540,8 +2541,12 @@ testIframeWithCallback( // Remove body handler manually since it's outside the fixture jQuery( "body" ).off( "focusin.iframeTest" ); + + } else { + // Opera 12 (pre-Blink) doesn't select anything + assert.ok( true, "SOFTFAIL: no focus event fired in the iframe" ); } -); +}); testIframeWithCallback( "jQuery.ready promise", diff --git a/test/unit/support.js b/test/unit/support.js index 80ea58ef0..93fba8701 100644 --- a/test/unit/support.js +++ b/test/unit/support.js @@ -73,6 +73,23 @@ testIframeWithCallback( "radioValue": true, "reliableMarginLeft": true }; + } else if ( /opera.*version\/12\.1/i.test( userAgent ) ) { + expected = { + "ajax": true, + "boxSizingReliable": true, + "checkClone": true, + "checkOn": true, + "clearCloneStyle": true, + "cors": true, + "createHTMLDocument": true, + "focusin": false, + "noCloneChecked": true, + "optSelected": true, + "pixelMarginRight": true, + "pixelPosition": true, + "radioValue": false, + "reliableMarginLeft": false + }; } else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) { expected = { "ajax": true, @@ -161,6 +178,22 @@ testIframeWithCallback( "radioValue": true, "reliableMarginLeft": true }; + } else if ( /5\.1(\.\d+|) safari/i.test( userAgent ) ) { + expected = { + "ajax": true, + "boxSizingReliable": true, + "checkClone": false, + "checkOn": false, + "clearCloneStyle": true, + "cors": true, + "focusinBubbles": false, + "noCloneChecked": true, + "optDisabled": true, + "optSelected": true, + "pixelPosition": false, + "radioValue": true, + "reliableMarginRight": true + }; } else if ( /firefox/i.test( userAgent ) ) { expected = { "ajax": true, @@ -212,7 +245,7 @@ testIframeWithCallback( "radioValue": true, "reliableMarginLeft": true }; - } else if ( /iphone os 7_/i.test( userAgent ) ) { + } else if ( /iphone os (?:6|7)_/i.test( userAgent ) ) { expected = { "ajax": true, "boxSizingReliable": true, -- 2.39.5