aboutsummaryrefslogtreecommitdiffstats
path: root/src/support.js
blob: ec15b16f31d3085a9e5bbd3621bf86819e87c684 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
define([
	"./core",
	"./core/swap",
	// This is listed as a dependency for build order, but it's still optional in builds
	"./core/ready"
], function( jQuery ) {

jQuery.support = (function( support ) {
	var container, marginDiv, divStyle,
		// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
		divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",
		docElem = document.documentElement,
		input = document.createElement("input"),
		fragment = document.createDocumentFragment(),
		div = document.createElement("div"),
		select = document.createElement("select"),
		opt = select.appendChild( document.createElement("option") );

	// Finish early in limited environments
	if ( !input.type ) {
		return support;
	}

	input.type = "checkbox";

	// Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
	// Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
	support.checkOn = input.value !== "";

	// Must access the parent to make an option select properly
	// Support: IE9, IE10
	support.optSelected = opt.selected;

	// This is hard-coded to true for compatibility reasons,
	// all supported browsers passed the test.
	support.boxSizing = true;

	// Will be defined later
	support.reliableMarginRight = true;
	support.boxSizingReliable = true;
	support.pixelPosition = false;

	// Make sure checked status is properly cloned
	// Support: IE9, IE10
	input.checked = true;
	support.noCloneChecked = input.cloneNode( true ).checked;

	// Make sure that the options inside disabled selects aren't marked as disabled
	// (WebKit marks them as disabled)
	select.disabled = true;
	support.optDisabled = !opt.disabled;

	// Check if an input maintains its value after becoming a radio
	// Support: IE9, IE10
	input = document.createElement("input");
	input.value = "t";
	input.type = "radio";
	support.radioValue = input.value === "t";

	// #11217 - WebKit loses check when the name is after the checked attribute
	input.setAttribute( "checked", "t" );
	input.setAttribute( "name", "t" );

	fragment.appendChild( input );

	// Support: Safari 5.1, Android 4.x, Android 2.3
	// old WebKit doesn't clone checked state correctly in fragments
	support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;

	// Support: Firefox, Chrome, Safari
	// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
	support.focusinBubbles = "onfocusin" in window;

	div.style.backgroundClip = "content-box";
	div.cloneNode( true ).style.backgroundClip = "";
	support.clearCloneStyle = div.style.backgroundClip === "content-box";

	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.
	docElem.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%";

	// Use window.getComputedStyle because jsdom on node.js will break without it.
	if ( window.getComputedStyle ) {
		divStyle = window.getComputedStyle( div, null );
		support.pixelPosition = ( divStyle || {} ).top !== "1%";
		support.boxSizingReliable = ( divStyle || { width: "4px" } ).width === "4px";

		// Support: Android 2.3
		// Check if div with explicit width and no margin-right incorrectly
		// gets computed margin-right based on width of container. (#3333)
		// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
		marginDiv = div.appendChild( document.createElement( "div" ) );
		marginDiv.style.cssText = div.style.cssText = divReset;
		marginDiv.style.marginRight = marginDiv.style.width = "0";
		div.style.width = "1px";

		support.reliableMarginRight =
			!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
	}

	docElem.removeChild( container );

	return support;
})( {} );

});