@@ -28,6 +28,12 @@ define( [
2828 // Executing both pixelPosition & boxSizingReliable tests require only one layout
2929 // so they're executed at the same time to save the second computation.
3030 function computeStyleTests ( ) {
31+
32+ // This is a singleton, we need to execute it only once
33+ if ( ! div ) {
34+ return ;
35+ }
36+
3137 div . style . cssText =
3238 "box-sizing:border-box;" +
3339 "position:relative;display:block;" +
@@ -38,6 +44,8 @@ define( [
3844
3945 var divStyle = window . getComputedStyle ( div ) ;
4046 pixelPositionVal = divStyle . top !== "1%" ;
47+
48+ // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44+
4149 reliableMarginLeftVal = divStyle . marginLeft === "2px" ;
4250 boxSizingReliableVal = divStyle . width === "4px" ;
4351
@@ -47,39 +55,27 @@ define( [
4755 pixelMarginRightVal = divStyle . marginRight === "4px" ;
4856
4957 documentElement . removeChild ( container ) ;
58+
59+ // Nullify the div so it wouldn't be stored in the memory and
60+ // it will also be a sign that checks already performed
61+ div = null ;
5062 }
5163
5264 jQuery . extend ( support , {
5365 pixelPosition : function ( ) {
54-
55- // This test is executed only once but we still do memoizing
56- // since we can use the boxSizingReliable pre-computing.
57- // No need to check if the test was already performed, though.
5866 computeStyleTests ( ) ;
5967 return pixelPositionVal ;
6068 } ,
6169 boxSizingReliable : function ( ) {
62- if ( boxSizingReliableVal == null ) {
63- computeStyleTests ( ) ;
64- }
70+ computeStyleTests ( ) ;
6571 return boxSizingReliableVal ;
6672 } ,
6773 pixelMarginRight : function ( ) {
68-
69- // Support: Android 4.0 - 4.3 only
70- // We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
71- // since that compresses better and they're computed together anyway.
72- if ( boxSizingReliableVal == null ) {
73- computeStyleTests ( ) ;
74- }
74+ computeStyleTests ( ) ;
7575 return pixelMarginRightVal ;
7676 } ,
7777 reliableMarginLeft : function ( ) {
78-
79- // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44+
80- if ( boxSizingReliableVal == null ) {
81- computeStyleTests ( ) ;
82- }
78+ computeStyleTests ( ) ;
8379 return reliableMarginLeftVal ;
8480 }
8581 } ) ;
0 commit comments