aboutsummaryrefslogtreecommitdiffstats
path: root/src/css/support.js
blob: 93459c6b69203a07a7b98058eec7cdd59b8495ad (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
import { document } from "../var/document.js";
import { documentElement } from "../var/documentElement.js";
import { support } from "../var/support.js";

( function() {

var reliableTrDimensionsVal,
	div = document.createElement( "div" );

// Finish early in limited (non-browser) environments
if ( !div.style ) {
	return;
}

// Support: IE 10 - 11+
// IE misreports `getComputedStyle` of table rows with width/height
// set in CSS while `offset*` properties report correct values.
// Support: Firefox 70+
// Only Firefox includes border widths
// in computed dimensions. (gh-4529)
support.reliableTrDimensions = function() {
	var table, tr, trStyle;
	if ( reliableTrDimensionsVal == null ) {
		table = document.createElement( "table" );
		tr = document.createElement( "tr" );

		table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
		tr.style.cssText = "box-sizing:content-box;border:1px solid";

		// Support: Chrome 86+
		// Height set through cssText does not get applied.
		// Computed height then comes back as 0.
		tr.style.height = "1px";
		div.style.height = "9px";

		// Support: Android Chrome 86+
		// In our bodyBackground.html iframe,
		// display for all div elements is set to "inline",
		// which causes a problem only in Android Chrome, but
		// not consistently across all devices.
		// Ensuring the div is `display: block`
		// gets around this issue.
		div.style.display = "block";

		documentElement
			.appendChild( table )
			.appendChild( tr )
			.appendChild( div );

		// Don't run until window is visible
		if ( table.offsetWidth === 0 ) {
			documentElement.removeChild( table );
			return;
		}

		trStyle = window.getComputedStyle( tr );
		reliableTrDimensionsVal = ( Math.round( parseFloat( trStyle.height ) ) +
			Math.round( parseFloat( trStyle.borderTopWidth ) ) +
			Math.round( parseFloat( trStyle.borderBottomWidth ) ) ) === tr.offsetHeight;

		documentElement.removeChild( table );
	}
	return reliableTrDimensionsVal;
};
} )();

export { support };