| 14217 |
anikendra |
1 |
define([
|
|
|
2 |
"../core",
|
|
|
3 |
"../var/support"
|
|
|
4 |
], function( jQuery, support ) {
|
|
|
5 |
|
|
|
6 |
(function() {
|
|
|
7 |
var pixelPositionVal, boxSizingReliableVal,
|
|
|
8 |
docElem = document.documentElement,
|
|
|
9 |
container = document.createElement( "div" ),
|
|
|
10 |
div = document.createElement( "div" );
|
|
|
11 |
|
|
|
12 |
if ( !div.style ) {
|
|
|
13 |
return;
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
// Support: IE9-11+
|
|
|
17 |
// Style of cloned element affects source element cloned (#8908)
|
|
|
18 |
div.style.backgroundClip = "content-box";
|
|
|
19 |
div.cloneNode( true ).style.backgroundClip = "";
|
|
|
20 |
support.clearCloneStyle = div.style.backgroundClip === "content-box";
|
|
|
21 |
|
|
|
22 |
container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
|
|
|
23 |
"position:absolute";
|
|
|
24 |
container.appendChild( div );
|
|
|
25 |
|
|
|
26 |
// Executing both pixelPosition & boxSizingReliable tests require only one layout
|
|
|
27 |
// so they're executed at the same time to save the second computation.
|
|
|
28 |
function computePixelPositionAndBoxSizingReliable() {
|
|
|
29 |
div.style.cssText =
|
|
|
30 |
// Support: Firefox<29, Android 2.3
|
|
|
31 |
// Vendor-prefix box-sizing
|
|
|
32 |
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
|
|
|
33 |
"box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
|
|
|
34 |
"border:1px;padding:1px;width:4px;position:absolute";
|
|
|
35 |
div.innerHTML = "";
|
|
|
36 |
docElem.appendChild( container );
|
|
|
37 |
|
|
|
38 |
var divStyle = window.getComputedStyle( div, null );
|
|
|
39 |
pixelPositionVal = divStyle.top !== "1%";
|
|
|
40 |
boxSizingReliableVal = divStyle.width === "4px";
|
|
|
41 |
|
|
|
42 |
docElem.removeChild( container );
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
// Support: node.js jsdom
|
|
|
46 |
// Don't assume that getComputedStyle is a property of the global object
|
|
|
47 |
if ( window.getComputedStyle ) {
|
|
|
48 |
jQuery.extend( support, {
|
|
|
49 |
pixelPosition: function() {
|
|
|
50 |
|
|
|
51 |
// This test is executed only once but we still do memoizing
|
|
|
52 |
// since we can use the boxSizingReliable pre-computing.
|
|
|
53 |
// No need to check if the test was already performed, though.
|
|
|
54 |
computePixelPositionAndBoxSizingReliable();
|
|
|
55 |
return pixelPositionVal;
|
|
|
56 |
},
|
|
|
57 |
boxSizingReliable: function() {
|
|
|
58 |
if ( boxSizingReliableVal == null ) {
|
|
|
59 |
computePixelPositionAndBoxSizingReliable();
|
|
|
60 |
}
|
|
|
61 |
return boxSizingReliableVal;
|
|
|
62 |
},
|
|
|
63 |
reliableMarginRight: function() {
|
|
|
64 |
|
|
|
65 |
// Support: Android 2.3
|
|
|
66 |
// Check if div with explicit width and no margin-right incorrectly
|
|
|
67 |
// gets computed margin-right based on width of container. (#3333)
|
|
|
68 |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
|
69 |
// This support function is only executed once so no memoizing is needed.
|
|
|
70 |
var ret,
|
|
|
71 |
marginDiv = div.appendChild( document.createElement( "div" ) );
|
|
|
72 |
|
|
|
73 |
// Reset CSS: box-sizing; display; margin; border; padding
|
|
|
74 |
marginDiv.style.cssText = div.style.cssText =
|
|
|
75 |
// Support: Firefox<29, Android 2.3
|
|
|
76 |
// Vendor-prefix box-sizing
|
|
|
77 |
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
|
|
|
78 |
"box-sizing:content-box;display:block;margin:0;border:0;padding:0";
|
|
|
79 |
marginDiv.style.marginRight = marginDiv.style.width = "0";
|
|
|
80 |
div.style.width = "1px";
|
|
|
81 |
docElem.appendChild( container );
|
|
|
82 |
|
|
|
83 |
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
|
|
|
84 |
|
|
|
85 |
docElem.removeChild( container );
|
|
|
86 |
div.removeChild( marginDiv );
|
|
|
87 |
|
|
|
88 |
return ret;
|
|
|
89 |
}
|
|
|
90 |
});
|
|
|
91 |
}
|
|
|
92 |
})();
|
|
|
93 |
|
|
|
94 |
return support;
|
|
|
95 |
|
|
|
96 |
});
|