Skip to content
Permalink
Browse files

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
  • Loading branch information...
mgol authored and dmethvin committed Apr 4, 2013
1 parent 1b61026 commit dca7681284731053124e6437c5bec58e030cc91d
Showing with 25 additions and 18 deletions.
  1. +3 −2 src/core.js
  2. +3 −2 src/css.js
  3. +4 −3 src/event.js
  4. +1 −1 src/manipulation.js
  5. +9 −5 src/support.js
  6. +0 −1 test/unit/ajax.js
  7. +2 −1 test/unit/css.js
  8. +2 −1 test/unit/dimensions.js
  9. +1 −2 test/unit/offset.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" ) ) {
@@ -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" },
@@ -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.

This comment has been minimized.

@markelog

markelog Feb 6, 2014

Member

@mzgol this is incorrect, now you are confusing everyone :-(

This comment has been minimized.

@markelog

markelog Feb 6, 2014

Member

I will post on https://bugzilla.mozilla.org/show_bug.cgi?id=968065 with detailed explanation soon

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 ) {

@@ -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 ) ) {

@@ -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;
@@ -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();
});
});
@@ -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("<div style='width:300px;height:300px;margin:2px;padding:2px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>"),
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
var el_dis = jQuery("<div style='width:300px;height:300px;margin:2px;padding:2px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;'>test</div>"),
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");
@@ -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("<div style='width:114px;height:114px;margin:5px;padding:3px;border:4px solid white;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>").appendTo("#qunit-fixture"),
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
var el_bb = jQuery("<div style='width:114px;height:114px;margin:5px;padding:3px;border:4px solid white;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;'>test</div>").appendTo("#qunit-fixture"),
el = jQuery("<div style='width:100px;height:100px;margin:5px;padding:3px;border:4px solid white;'>test</div>").appendTo("#qunit-fixture"),
expected = 100;

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

0 comments on commit dca7681

Please sign in to comment.
You can’t perform that action at this time.