-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not crash when unsetting scrollToRow #62
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict' | ||
|
||
var jsdom = require('jsdom') | ||
|
||
// setup the simplest document possible | ||
var doc = jsdom.jsdom('<!doctype html><html><body></body></html>') | ||
|
||
// get the window object out of the document | ||
var win = doc.defaultView | ||
|
||
// set globals for mocha that make access to document and window feel | ||
// natural in the test environment | ||
global.document = doc | ||
global.window = win | ||
|
||
// take all properties of the window object and also attach it to the | ||
// mocha global object | ||
propagateToGlobal(win) | ||
|
||
// from mocha-jsdom https://github.com/rstacruz/mocha-jsdom/blob/master/index.js#L80 | ||
function propagateToGlobal (window) { | ||
for (let key in window) { | ||
if (!window.hasOwnProperty(key)) continue | ||
if (key in global) continue | ||
|
||
global[key] = window[key] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -912,7 +912,7 @@ var FixedDataTable = React.createClass({ | |
} | ||
|
||
var lastScrollToRow = oldState ? oldState.scrollToRow : undefined; | ||
if (props.scrollToRow !== lastScrollToRow) { | ||
if (typeof props.scrollToRow !== 'undefined' && props.scrollToRow !== null && props.scrollToRow !== lastScrollToRow) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should introduce lodash into our lib and use _.isNil instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be cool, but I guess I would argue that could be a separate PR after this one (if this is accepted). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to implement something similar for the other: scrollTop, scrollToRow and scrollToColumn There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought so too, but they weren't failing similar tests, while this one was, so I opted not to. |
||
scrollState = this._scrollHelper.scrollRowIntoView(props.scrollToRow); | ||
firstRowIndex = scrollState.index; | ||
firstRowOffset = scrollState.offset; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing semicolons throughout this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I get for copying it from somewhere else. Sure would be nice to have ESLint set up for this project. Any interest in a PR doing so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, would love it!