CSS: Make .css("width") & .css("height") return fractional values

Fixes gh-1724
Closes gh-2454
Refs gh-2439
This commit is contained in:
Michał Gołębiowski
2015-07-02 01:20:18 +02:00
parent 203979d153
commit 23212b34e6
5 changed files with 117 additions and 27 deletions

View File

@@ -4,8 +4,8 @@ define([
], function( jQuery, support ) {
(function() {
var div, container, style, a, pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal,
reliableHiddenOffsetsVal, reliableMarginRightVal;
var div, container, style, a, pixelPositionVal, boxSizingReliableVal, gBCRDimensionsVal,
pixelMarginRightVal, reliableHiddenOffsetsVal, reliableMarginRightVal;
// Setup
div = document.createElement( "div" );
@@ -55,6 +55,13 @@ define([
return boxSizingReliableVal;
},
gBCRDimensions: function() {
if ( pixelPositionVal == null ) {
computeStyleTests();
}
return gBCRDimensionsVal;
},
pixelMarginRight: function() {
// Support: Android 4.0-4.3
if ( pixelPositionVal == null ) {
@@ -105,6 +112,10 @@ define([
pixelPositionVal = boxSizingReliableVal = false;
pixelMarginRightVal = reliableMarginRightVal = true;
// Support: IE<9
// In IE8 gBCR doesn't report width & height.
gBCRDimensionsVal = !!div.getBoundingClientRect().width;
// Check for getComputedStyle so that this code is not run in IE<9.
if ( window.getComputedStyle ) {
divStyle = window.getComputedStyle( div );