mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
CSS: Detect more WebKit styles erroneously reported as percentages
Ref 692f9d4db3
Fixes gh-3777
Closes gh-3778
This commit is contained in:
@@ -2,7 +2,6 @@ define( [
|
||||
"./core",
|
||||
"./var/pnum",
|
||||
"./core/access",
|
||||
"./css/var/rmargin",
|
||||
"./var/document",
|
||||
"./var/rcssNum",
|
||||
"./css/var/rnumnonpx",
|
||||
@@ -17,7 +16,7 @@ define( [
|
||||
"./core/init",
|
||||
"./core/ready",
|
||||
"./selector" // contains
|
||||
], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand,
|
||||
], function( jQuery, pnum, access, document, rcssNum, rnumnonpx, cssExpand,
|
||||
getStyles, swap, curCSS, adjustCSS, addGetHookIf, support ) {
|
||||
|
||||
"use strict";
|
||||
@@ -447,7 +446,7 @@ jQuery.each( {
|
||||
}
|
||||
};
|
||||
|
||||
if ( !rmargin.test( prefix ) ) {
|
||||
if ( prefix !== "margin" ) {
|
||||
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
define( [
|
||||
"../core",
|
||||
"./var/rboxStyle",
|
||||
"./var/rnumnonpx",
|
||||
"./var/rmargin",
|
||||
"./var/getStyles",
|
||||
"./support",
|
||||
"../selector" // Get jQuery.contains
|
||||
], function( jQuery, rnumnonpx, rmargin, getStyles, support ) {
|
||||
], function( jQuery, rboxStyle, rnumnonpx, getStyles, support ) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -35,7 +35,7 @@ function curCSS( elem, name, computed ) {
|
||||
// but width seems to be reliably pixels.
|
||||
// This is against the CSSOM draft spec:
|
||||
// https://drafts.csswg.org/cssom/#resolved-values
|
||||
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
||||
if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
|
||||
|
||||
// Remember the original values
|
||||
width = style.width;
|
||||
|
||||
@@ -32,10 +32,10 @@ define( [
|
||||
// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
|
||||
reliableMarginLeftVal = divStyle.marginLeft === "12px";
|
||||
|
||||
// Support: Android 4.0 - 4.3 only
|
||||
// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
|
||||
// Some styles come back with percentage values, even though they shouldn't
|
||||
div.style.marginRight = "60%";
|
||||
pixelMarginRightVal = divStyle.marginRight === "36px";
|
||||
div.style.right = "60%";
|
||||
pixelBoxStylesVal = divStyle.right === "36px";
|
||||
|
||||
// Support: IE 9 - 11 only
|
||||
// Detect misreporting of content dimensions for box-sizing:border-box elements
|
||||
@@ -53,7 +53,7 @@ define( [
|
||||
div = null;
|
||||
}
|
||||
|
||||
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelMarginRightVal,
|
||||
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
|
||||
reliableMarginLeftVal,
|
||||
container = document.createElement( "div" ),
|
||||
div = document.createElement( "div" );
|
||||
@@ -74,14 +74,14 @@ define( [
|
||||
computeStyleTests();
|
||||
return boxSizingReliableVal;
|
||||
},
|
||||
pixelBoxStyles: function() {
|
||||
computeStyleTests();
|
||||
return pixelBoxStylesVal;
|
||||
},
|
||||
pixelPosition: function() {
|
||||
computeStyleTests();
|
||||
return pixelPositionVal;
|
||||
},
|
||||
pixelMarginRight: function() {
|
||||
computeStyleTests();
|
||||
return pixelMarginRightVal;
|
||||
},
|
||||
reliableMarginLeft: function() {
|
||||
computeStyleTests();
|
||||
return reliableMarginLeftVal;
|
||||
|
||||
7
src/css/var/rboxStyle.js
Normal file
7
src/css/var/rboxStyle.js
Normal file
@@ -0,0 +1,7 @@
|
||||
define( [
|
||||
"./cssExpand"
|
||||
], function( cssExpand ) {
|
||||
"use strict";
|
||||
|
||||
return new RegExp( cssExpand.join( "|" ), "i" );
|
||||
} );
|
||||
@@ -1,5 +0,0 @@
|
||||
define( function() {
|
||||
"use strict";
|
||||
|
||||
return ( /^margin/ );
|
||||
} );
|
||||
Reference in New Issue
Block a user