aboutsummaryrefslogtreecommitdiffstats
path: root/src/css
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2015-02-05 02:11:58 +0100
committerMichał Gołębiowski <m.goleb@gmail.com>2015-02-05 02:48:32 +0100
commit45ec73f55618cd080867a98b42b9ab80409cab2e (patch)
tree644fba8cb22a07f7bb282a69561c4b7a37dc9f25 /src/css
parentcdfc2d092afad5a3e5b3978b04b402a1ee9dce79 (diff)
downloadjquery-45ec73f55618cd080867a98b42b9ab80409cab2e.tar.gz
jquery-45ec73f55618cd080867a98b42b9ab80409cab2e.zip
CSS: save 20 bytes in css/support
Refs gh-1842
Diffstat (limited to 'src/css')
-rw-r--r--src/css/curCSS.js5
-rw-r--r--src/css/support.js36
2 files changed, 20 insertions, 21 deletions
diff --git a/src/css/curCSS.js b/src/css/curCSS.js
index aba57ad37..207139726 100644
--- a/src/css/curCSS.js
+++ b/src/css/curCSS.js
@@ -25,6 +25,11 @@ function curCSS( elem, name, computed ) {
ret = jQuery.style( elem, name );
}
+ // 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:
+ // http://dev.w3.org/csswg/cssom/#resolved-values
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
// Remember the original values
diff --git a/src/css/support.js b/src/css/support.js
index b26cc568e..4dd22bd2a 100644
--- a/src/css/support.js
+++ b/src/css/support.js
@@ -20,25 +20,28 @@ define([
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
- container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;margin-top:1px;" +
- "position:absolute";
+ container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
+ "padding:0;margin-top:1px;position:absolute";
container.appendChild( div );
// Executing both pixelPosition & boxSizingReliable tests require only one layout
// so they're executed at the same time to save the second computation.
- function computePixelPositionAndBoxSizingReliable() {
+ function computeStyleTests() {
div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:border-box;box-sizing:border-box;" +
- "display:block;margin-top:1%;top:1%;" +
- "border:1px;padding:1px;width:4px;position:absolute";
+ "display:block;position:absolute;" +
+ "margin:0;margin-top:1%;margin-right:50%;" +
+ "border:1px;padding:1px;" +
+ "top:1%;width:50%;height:4px";
div.innerHTML = "";
documentElement.appendChild( container );
var divStyle = window.getComputedStyle( div, null );
pixelPositionVal = divStyle.top !== "1%";
- boxSizingReliableVal = divStyle.width === "4px";
+ boxSizingReliableVal = divStyle.height === "4px";
+ pixelMarginRightVal = divStyle.marginRight === "4px";
documentElement.removeChild( container );
}
@@ -48,33 +51,24 @@ define([
if ( window.getComputedStyle ) {
jQuery.extend( support, {
pixelPosition: function() {
-
// This test is executed only once but we still do memoizing
// since we can use the boxSizingReliable pre-computing.
// No need to check if the test was already performed, though.
- computePixelPositionAndBoxSizingReliable();
+ computeStyleTests();
return pixelPositionVal;
},
boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) {
- computePixelPositionAndBoxSizingReliable();
+ computeStyleTests();
}
return boxSizingReliableVal;
},
pixelMarginRight: function() {
// Support: Android 4.0-4.3
- // 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:
- // http://dev.w3.org/csswg/cssom/#resolved-values
- if ( pixelMarginRightVal == null ) {
- div.style.cssText = "display:block;width:50%;border:0;margin:0;padding:0;" +
- "margin-right:50%";
- documentElement.appendChild( container );
- pixelMarginRightVal =
- window.getComputedStyle( div, null ).marginRight === "4px";
- documentElement.removeChild( container );
+ // We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
+ // since that compresses better and they're computed together anyway.
+ if ( boxSizingReliableVal == null ) {
+ computeStyleTests();
}
return pixelMarginRightVal;
},