From dca7681284731053124e6437c5bec58e030cc91d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Thu, 4 Apr 2013 22:04:39 +0200 Subject: [PATCH] Improve CSS and `Support:` comments. Close gh-1220. 1) corrected box-sizing rules order - the unprefixed value should always be the last one 2) removed last semi-colons in CSS rules 3) updated support comments code review changes + more consistent comment spacing --- src/core.js | 5 +++-- src/css.js | 5 +++-- src/event.js | 7 ++++--- src/manipulation.js | 2 +- src/support.js | 14 +++++++++----- test/unit/ajax.js | 1 - test/unit/css.js | 3 ++- test/unit/dimensions.js | 3 ++- test/unit/offset.js | 3 +-- 9 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/core.js b/src/core.js index 9a288fa1b..a35e79893 100644 --- a/src/core.js +++ b/src/core.js @@ -409,7 +409,7 @@ jQuery.extend({ if ( obj == null ) { return String( obj ); } - // Support: Safari <=5.1 (functionish RegExp) + // Support: Safari <= 5.1 (functionish RegExp) return typeof obj === "object" || typeof obj === "function" ? class2type[ core_toString.call(obj) ] || "object" : typeof obj; @@ -424,9 +424,10 @@ jQuery.extend({ return false; } - // Support: Firefox >16 + // Support: Firefox <20 // The try/catch suppresses exceptions thrown when attempting to access // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 try { if ( obj.constructor && !core_hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { diff --git a/src/css.js b/src/css.js index 522982b3f..bbd56ad7b 100644 --- a/src/css.js +++ b/src/css.js @@ -295,9 +295,8 @@ curCSS = function( elem, name, _computed ) { ret = jQuery.style( elem, name ); } - // Support: Chrome <17, Safari 5.1 + // Support: Safari 5.1 // A tribute to the "awesome hack by Dean Edwards" - // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right // Safari 5.1.7 (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 ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { @@ -484,10 +483,12 @@ jQuery.each([ "height", "width" ], function( i, name ) { // These hooks cannot be added until DOM ready because the support test // for it is not run until after DOM ready jQuery(function() { + // Support: Android 2.3 if ( !jQuery.support.reliableMarginRight ) { jQuery.cssHooks.marginRight = { get: function( elem, computed ) { if ( computed ) { + // Support: Android 2.3 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right // Work around by temporarily setting element display to inline-block return jQuery.swap( elem, { "display": "inline-block" }, diff --git a/src/event.js b/src/event.js index a9620e241..45e82ccc4 100644 --- a/src/event.js +++ b/src/event.js @@ -508,7 +508,7 @@ jQuery.event = { event[ prop ] = originalEvent[ prop ]; } - // Support: Chrome 23+, Safari? + // 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; @@ -554,7 +554,8 @@ jQuery.event = { beforeunload: { postDispatch: function( event ) { - // Support: Firefox 10+ + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. if ( event.result !== undefined ) { event.originalEvent.returnValue = event.result; } @@ -685,7 +686,7 @@ jQuery.each({ }); // Create "bubbling" focus and blur events -// Support: Firefox 10+ +// Support: Firefox, Chrome, Safari if ( !jQuery.support.focusinBubbles ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { diff --git a/src/manipulation.js b/src/manipulation.js index f3c729fdf..8f0422694 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -318,7 +318,7 @@ jQuery.extend({ clone = elem.cloneNode( true ), inPage = jQuery.contains( elem.ownerDocument, elem ); - // Support: IE >=9 + // Support: IE >= 9 // Fix Cloning issues if ( !jQuery.support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) { diff --git a/src/support.js b/src/support.js index 52f832f42..a28fb971f 100644 --- a/src/support.js +++ b/src/support.js @@ -12,6 +12,7 @@ jQuery.support = (function( support ) { input.type = "checkbox"; + // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere) support.checkOn = input.value !== ""; @@ -38,7 +39,7 @@ jQuery.support = (function( support ) { support.optDisabled = !opt.disabled; // Check if an input maintains its value after becoming a radio - // Support: IE9, IE10, Opera + // Support: IE9, IE10 input = document.createElement("input"); input.value = "t"; input.type = "radio"; @@ -50,10 +51,11 @@ jQuery.support = (function( support ) { fragment.appendChild( input ); + // Support: Safari 5.1, Android 4.x, Android 2.3 // old WebKit doesn't clone checked state correctly in fragments support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - // Support: Firefox 17+ + // Support: Firefox, Chrome, Safari // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) support.focusinBubbles = "onfocusin" in window; @@ -64,7 +66,8 @@ jQuery.support = (function( support ) { // Run tests that need a body at doc ready jQuery(function() { var container, marginDiv, - divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", + // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). + divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box", body = document.getElementsByTagName("body")[ 0 ]; if ( !body ) { @@ -78,7 +81,8 @@ jQuery.support = (function( support ) { // Check box-sizing and margin behavior. body.appendChild( container ).appendChild( div ); div.innerHTML = ""; - div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; + // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). + div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%"; // Workaround failing boxSizing test due to offsetWidth returning wrong value // with some non-1 values of body zoom, ticket #13543 @@ -91,9 +95,9 @@ jQuery.support = (function( support ) { support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; + // Support: Android 2.3 // Check if div with explicit width and no margin-right incorrectly // gets computed margin-right based on width of container. (#3333) - // Fails in WebKit before Feb 2011 nightlies // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right marginDiv = div.appendChild( document.createElement("div") ); marginDiv.style.cssText = div.style.cssText = divReset; diff --git a/test/unit/ajax.js b/test/unit/ajax.js index a0a2abf4a..0de0da05f 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1045,7 +1045,6 @@ module( "ajax", { ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" ); jQuery.ajax( url("data/statusText.php?status=404&text=World") ).fail(function( jqXHR, statusText ) { strictEqual( statusText, "error", "callback status text ok for error" ); - // ok( jqXHR.statusText === "World" || jQuery.browser.safari && jqXHR.statusText === "Not Found", "jqXHR status text ok for error (" + jqXHR.statusText + ")" ); start(); }); }); diff --git a/test/unit/css.js b/test/unit/css.js index dc851f745..8a2ecfb60 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -775,7 +775,8 @@ test("Do not append px (#9548, #12990)", function() { test("css('width') and css('height') should respect box-sizing, see #11004", function() { expect( 4 ); - var el_dis = jQuery("
test
"), + // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). + var el_dis = jQuery("
test
"), el = el_dis.clone().appendTo("#qunit-fixture"); equal( el.css("width"), el.css("width", el.css("width")).css("width"), "css('width') is not respecting box-sizing, see #11004"); diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index bcb7b7f2c..c7d1281f2 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -407,7 +407,8 @@ test( "getters on non elements should return null", function() { test("setters with and without box-sizing:border-box", function(){ expect(20); - var el_bb = jQuery("
test
").appendTo("#qunit-fixture"), + // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). + var el_bb = jQuery("
test
").appendTo("#qunit-fixture"), el = jQuery("
test
").appendTo("#qunit-fixture"), expected = 100; diff --git a/test/unit/offset.js b/test/unit/offset.js index 08b90c3b8..0d8bcc726 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -18,8 +18,7 @@ var supportsScroll, supportsFixedPosition, supportsScroll = document.documentElement.scrollTop || document.body.scrollTop; forceScroll.detach(); - // Safari subtracts parent border width here (which is 5px) - supportsFixedPosition = checkFixed[0].offsetTop === 20 || checkFixed[0].offsetTop === 15; + supportsFixedPosition = checkFixed[0].offsetTop === 20; checkFixed.remove(); }; -- 2.39.5