Manipulation: Support $el.html(selfRemovingScript) (#5378)
[jquery.git] / src / css / support.js
blobc7229e93a4737a503e89cb519d193aeb821b8f2b
1 import { document } from "../var/document.js";
2 import { documentElement } from "../var/documentElement.js";
3 import { support } from "../var/support.js";
5 ( function() {
7 var reliableTrDimensionsVal,
8         div = document.createElement( "div" );
10 // Finish early in limited (non-browser) environments
11 if ( !div.style ) {
12         return;
15 // Support: IE 10 - 11+
16 // IE misreports `getComputedStyle` of table rows with width/height
17 // set in CSS while `offset*` properties report correct values.
18 // Support: Firefox 70+
19 // Only Firefox includes border widths
20 // in computed dimensions. (gh-4529)
21 support.reliableTrDimensions = function() {
22         var table, tr, trStyle;
23         if ( reliableTrDimensionsVal == null ) {
24                 table = document.createElement( "table" );
25                 tr = document.createElement( "tr" );
27                 table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
28                 tr.style.cssText = "box-sizing:content-box;border:1px solid";
30                 // Support: Chrome 86+
31                 // Height set through cssText does not get applied.
32                 // Computed height then comes back as 0.
33                 tr.style.height = "1px";
34                 div.style.height = "9px";
36                 // Support: Android Chrome 86+
37                 // In our bodyBackground.html iframe,
38                 // display for all div elements is set to "inline",
39                 // which causes a problem only in Android Chrome, but
40                 // not consistently across all devices.
41                 // Ensuring the div is `display: block`
42                 // gets around this issue.
43                 div.style.display = "block";
45                 documentElement
46                         .appendChild( table )
47                         .appendChild( tr )
48                         .appendChild( div );
50                 // Don't run until window is visible
51                 if ( table.offsetWidth === 0 ) {
52                         documentElement.removeChild( table );
53                         return;
54                 }
56                 trStyle = window.getComputedStyle( tr );
57                 reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
58                                 parseInt( trStyle.borderTopWidth, 10 ) +
59                                 parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
61                 documentElement.removeChild( table );
62         }
63         return reliableTrDimensionsVal;
65 } )();
67 export { support };