[change] Fix the Dimensions.window value

Fixes issues in Safari from using window.innerWidth. Using
documentElement.clientWidth doesn't have issues and provides a more practical
value for the canvas width that excludes the width of scrollbars.

Fix #1369
Fix #1905
This commit is contained in:
Nicolas Gallagher
2021-04-08 18:20:19 -07:00
parent c4e2d7a919
commit 89cf78d529
2 changed files with 42 additions and 20 deletions
+12 -1
View File
@@ -6,5 +6,16 @@ class ResizeObserver {
observe() {}
unobserve() {}
}
window.ResizeObserver = ResizeObserver;
// JSDOM doesn't provide values for 'clientWidth' etc
Object.defineProperty(window.document.documentElement, 'clientHeight', {
get: function () {
return this._jsdomClientWidth || window.innerHeight;
}
});
Object.defineProperty(window.document.documentElement, 'clientWidth', {
get: function () {
return this._jsdomClientWidth || window.innerWidth;
}
});