Skip to content

Commit 0aecbfb

Browse files
author
Malte W
committed
Merge branch 'ponty96-fix/document-ssr'
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
2 parents f2c9f78 + bc965f0 commit 0aecbfb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Scrollbars.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,23 +303,25 @@ export default createClass({
303303
},
304304

305305
addListeners() {
306+
if (typeof document === 'undefined') return;
306307
this.refs.view.addEventListener('scroll', this.handleScroll);
307308
this.refs.barVertical.addEventListener('mousedown', this.handleVerticalTrackMouseDown);
308309
this.refs.barHorizontal.addEventListener('mousedown', this.handleHorizontalTrackMouseDown);
309310
this.refs.thumbVertical.addEventListener('mousedown', this.handleVerticalThumbMouseDown);
310311
this.refs.thumbHorizontal.addEventListener('mousedown', this.handleHorizontalThumbMouseDown);
311-
if (document) document.addEventListener('mouseup', this.handleDocumentMouseUp);
312-
if (window) window.addEventListener('resize', this.handleWindowResize);
312+
document.addEventListener('mouseup', this.handleDocumentMouseUp);
313+
window.addEventListener('resize', this.handleWindowResize);
313314
},
314315

315316
removeListeners() {
317+
if (typeof document === 'undefined') return;
316318
this.refs.view.removeEventListener('scroll', this.handleScroll);
317319
this.refs.barVertical.removeEventListener('mousedown', this.handleVerticalTrackMouseDown);
318320
this.refs.barHorizontal.removeEventListener('mousedown', this.handleHorizontalTrackMouseDown);
319321
this.refs.thumbVertical.removeEventListener('mousedown', this.handleVerticalThumbMouseDown);
320322
this.refs.thumbHorizontal.removeEventListener('mousedown', this.handleHorizontalThumbMouseDown);
321-
if (document) document.removeEventListener('mouseup', this.handleDocumentMouseUp);
322-
if (window) window.removeEventListener('resize', this.handleWindowResize);
323+
document.removeEventListener('mouseup', this.handleDocumentMouseUp);
324+
window.removeEventListener('resize', this.handleWindowResize);
323325
},
324326

325327
render() {

src/utils/getScrollbarWidth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let scrollbarWidth = false;
33

44
export default function getScrollbarWidth() {
55
if (scrollbarWidth !== false) return scrollbarWidth;
6-
if (document) {
6+
if (typeof document !== 'undefined') {
77
const div = document.createElement('div');
88
css(div, {
99
width: 100,

0 commit comments

Comments
 (0)