diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2019-10-14 18:41:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-14 18:41:35 +0200 |
commit | 26415e081b318dbe1d46d2b7c30e05f14c339b75 (patch) | |
tree | 5aa9babac570d914647259b5312cdb8a9c8303e3 /src/css/support.js | |
parent | ed66d5a22b37425abf5b63c361f91340de89c994 (diff) | |
download | jquery-26415e081b318dbe1d46d2b7c30e05f14c339b75.tar.gz jquery-26415e081b318dbe1d46d2b7c30e05f14c339b75.zip |
CSS: Workaround buggy getComputedStyle on table rows in IE/Edge
Fixes gh-4490
Closes gh-4506
Diffstat (limited to 'src/css/support.js')
-rw-r--r-- | src/css/support.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/css/support.js b/src/css/support.js new file mode 100644 index 000000000..053f494b2 --- /dev/null +++ b/src/css/support.js @@ -0,0 +1,40 @@ +define( [ + "../var/document", + "../var/documentElement", + "../var/support" +], function( document, documentElement, support ) { + +"use strict"; + +var reliableTrDimensionsVal; + +// Support: IE 11+, Edge 15 - 18+ +// IE/Edge misreport `getComputedStyle` of table rows with width/height +// set in CSS while `offset*` properties report correct values. +support.reliableTrDimensions = function() { + var table, tr, trChild; + if ( reliableTrDimensionsVal == null ) { + table = document.createElement( "table" ); + tr = document.createElement( "tr" ); + trChild = document.createElement( "div" ); + + table.style.cssText = "position:absolute;left:-11111px"; + tr.style.height = "1px"; + trChild.style.height = "9px"; + + documentElement + .appendChild( table ) + .appendChild( tr ) + .appendChild( trChild ); + + var trStyle = window.getComputedStyle( tr ); + reliableTrDimensionsVal = parseInt( trStyle.height ) > 3; + + documentElement.removeChild( table ); + } + return reliableTrDimensionsVal; +}; + +return support; + +} ); |