Mercurial > nebulaweb3
comparison default/node_modules/jquery/src/css/support.js @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1d038bc9b3d2 |
---|---|
1 define( [ | |
2 "../core", | |
3 "../var/document", | |
4 "../var/documentElement", | |
5 "../var/support" | |
6 ], function( jQuery, document, documentElement, support ) { | |
7 | |
8 "use strict"; | |
9 | |
10 ( function() { | |
11 | |
12 // Executing both pixelPosition & boxSizingReliable tests require only one layout | |
13 // so they're executed at the same time to save the second computation. | |
14 function computeStyleTests() { | |
15 | |
16 // This is a singleton, we need to execute it only once | |
17 if ( !div ) { | |
18 return; | |
19 } | |
20 | |
21 container.style.cssText = "position:absolute;left:-11111px;width:60px;" + | |
22 "margin-top:1px;padding:0;border:0"; | |
23 div.style.cssText = | |
24 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + | |
25 "margin:auto;border:1px;padding:1px;" + | |
26 "width:60%;top:1%"; | |
27 documentElement.appendChild( container ).appendChild( div ); | |
28 | |
29 var divStyle = window.getComputedStyle( div ); | |
30 pixelPositionVal = divStyle.top !== "1%"; | |
31 | |
32 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 | |
33 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; | |
34 | |
35 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 | |
36 // Some styles come back with percentage values, even though they shouldn't | |
37 div.style.right = "60%"; | |
38 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; | |
39 | |
40 // Support: IE 9 - 11 only | |
41 // Detect misreporting of content dimensions for box-sizing:border-box elements | |
42 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; | |
43 | |
44 // Support: IE 9 only | |
45 // Detect overflow:scroll screwiness (gh-3699) | |
46 div.style.position = "absolute"; | |
47 scrollboxSizeVal = div.offsetWidth === 36 || "absolute"; | |
48 | |
49 documentElement.removeChild( container ); | |
50 | |
51 // Nullify the div so it wouldn't be stored in the memory and | |
52 // it will also be a sign that checks already performed | |
53 div = null; | |
54 } | |
55 | |
56 function roundPixelMeasures( measure ) { | |
57 return Math.round( parseFloat( measure ) ); | |
58 } | |
59 | |
60 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, | |
61 reliableMarginLeftVal, | |
62 container = document.createElement( "div" ), | |
63 div = document.createElement( "div" ); | |
64 | |
65 // Finish early in limited (non-browser) environments | |
66 if ( !div.style ) { | |
67 return; | |
68 } | |
69 | |
70 // Support: IE <=9 - 11 only | |
71 // Style of cloned element affects source element cloned (#8908) | |
72 div.style.backgroundClip = "content-box"; | |
73 div.cloneNode( true ).style.backgroundClip = ""; | |
74 support.clearCloneStyle = div.style.backgroundClip === "content-box"; | |
75 | |
76 jQuery.extend( support, { | |
77 boxSizingReliable: function() { | |
78 computeStyleTests(); | |
79 return boxSizingReliableVal; | |
80 }, | |
81 pixelBoxStyles: function() { | |
82 computeStyleTests(); | |
83 return pixelBoxStylesVal; | |
84 }, | |
85 pixelPosition: function() { | |
86 computeStyleTests(); | |
87 return pixelPositionVal; | |
88 }, | |
89 reliableMarginLeft: function() { | |
90 computeStyleTests(); | |
91 return reliableMarginLeftVal; | |
92 }, | |
93 scrollboxSize: function() { | |
94 computeStyleTests(); | |
95 return scrollboxSizeVal; | |
96 } | |
97 } ); | |
98 } )(); | |
99 | |
100 return support; | |
101 | |
102 } ); |