Files
react-native-web/scripts/jest/setupFiles.js
T
Nicolas Gallagher 89cf78d529 [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
2021-04-20 10:44:46 -07:00

22 lines
560 B
JavaScript

/* eslint-env jasmine, jest */
// JSDOM doesn't implement ResizeObserver
class ResizeObserver {
disconnect() {}
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;
}
});