-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (33 loc) · 1.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// from jquery/src/support.js
function swap(elem, options, cb) {
var ret, name, old = {};
// Remember the old values, and insert the new ones
for (name in options) {
old[name] = elem.style[name];
elem.style[name] = options[name];
}
ret = cb(elem);
// Revert the old values
for (name in options) {
elem.style[name] = old[name];
}
return ret;
}
module.exports = (function() {
var body = document.getElementsByTagName("body")[0];
var div = document.createElement("div");
var hasBoxSizing = false;
if (!body) return false;
var container = document.createElement("div");
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
// Check box-sizing and margin behavior.
body.appendChild(container).appendChild( div );
div.innerHTML = "";
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%";
swap(body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
hasBoxSizing = div.offsetWidth === 4;
});
body.removeChild( container );
return hasBoxSizing;
})();