Skip to content

Commit

Permalink
CSS: Make the reliableTrDimensions support test work with Bootstrap CSS
Browse files Browse the repository at this point in the history
Bootstrap 5 includes the following CSS on the page:

```css
*,
*::before,
*::after {
  box-sizing: border-box;
}
```

That threw our `reliableTrDimensions` support test off. This change fixes the
support test and adds a unit test ensuring support test values on a page
including Bootstrap 5 CSS are the same as on a page without it.

Fixes gh-5270
Closes gh-5278
Ref gh-5279
  • Loading branch information
mgol committed Jul 10, 2023
1 parent e242187 commit 65b8503
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Gruntfile.js
Expand Up @@ -89,6 +89,10 @@ module.exports = function( grunt ) {
destPrefix: "external"
},
files: {
"bootstrap/bootstrap.css": "bootstrap/dist/css/bootstrap.css",
"bootstrap/bootstrap.min.css": "bootstrap/dist/css/bootstrap.min.css",
"bootstrap/bootstrap.min.css.map": "bootstrap/dist/css/bootstrap.min.css.map",

"core-js-bundle/core-js-bundle.js": "core-js-bundle/minified.js",
"core-js-bundle/LICENSE": "core-js-bundle/LICENSE",

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -27,6 +27,7 @@
"@babel/core": "7.10.5",
"@babel/plugin-transform-for-of": "7.10.4",
"@swc/core": "1.3.66",
"bootstrap": "5.3.0",
"colors": "1.4.0",
"commitplease": "3.2.0",
"core-js-bundle": "3.6.5",
Expand Down
4 changes: 2 additions & 2 deletions src/css/support.js
Expand Up @@ -25,7 +25,7 @@ support.reliableTrDimensions = function() {
tr = document.createElement( "tr" );

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

// Support: Chrome 86+
// Height set through cssText does not get applied.
Expand All @@ -38,7 +38,7 @@ support.reliableTrDimensions = function() {
// 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
// Ensuring the div is `display: block`
// gets around this issue.
div.style.display = "block";

Expand Down
20 changes: 20 additions & 0 deletions test/data/support/bootstrap.html
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="../../../external/bootstrap/bootstrap.min.css" class="stylesheet">
</head>
<body>
<div>
<script src="../../jquery.js"></script>
<script src="../iframeTest.js"></script>
<script src="getComputedSupport.js"></script>
</div>
<script>
startIframeTest(
getComputedStyle( document.body ),
getComputedSupport( jQuery.support )
);
</script>
</body>
</html>
12 changes: 12 additions & 0 deletions test/unit/support.js
Expand Up @@ -54,6 +54,18 @@ testIframe(
}
);

testIframe(
"Verify correctness of support tests with bootstrap CSS on the page",
"support/bootstrap.html",
function( assert, jQuery, window, document, bodyStyle, support ) {
assert.expect( 2 );
assert.strictEqual( bodyStyle.boxSizing, "border-box",
"border-box applied on body by Bootstrap" );
assert.deepEqual( jQuery.extend( {}, support ), computedSupport,
"Same support properties" );
}
);

( function() {
var expected, browserKey,
userAgent = window.navigator.userAgent,
Expand Down

0 comments on commit 65b8503

Please sign in to comment.