-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Validate if an element to scroll is actually scrollable #118
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #118 +/- ##
=======================================
Coverage 91.66% 91.66%
=======================================
Files 18 18
Lines 396 396
Branches 63 63
=======================================
Hits 363 363
Misses 29 29
Partials 4 4 ☔ View full report in Codecov by Sentry. |
36df5ff
to
0e044e0
Compare
0e044e0
to
13536da
Compare
ea32eb9
to
01245fa
Compare
01245fa
to
7755d68
Compare
7755d68
to
7546b00
Compare
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.
Left a couple of comments that are non-blocking
src/browser-scripts/scroll.ts
Outdated
throw new Error('Element ' + selector + ' has not been found at the page'); | ||
const overflowStyles = getComputedStyle(element)[overflowDirection].split(' '); | ||
if (!overflowStyles.includes('auto') && !overflowStyles.includes('scroll') && element !== document.documentElement) { | ||
throw new Error('Element ' + selector + ' is not scrollable'); |
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.
can we align using the formatting of errors strings? I see some exaples using the `` and some using '' + ''
could it be:
throw new Error(`Element ${selector} is not scrollable`);
src/browser-scripts/scroll.ts
Outdated
} | ||
element.scrollTop = top; | ||
element.scrollLeft = left; | ||
} | ||
|
||
export function getElementScrollPosition(selector: string): ScrollPosition { | ||
var element = document.querySelector(selector); |
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.
Away from the changes but can this be const
instead?
Issue #, if available:
Description of changes:
Make sure that we attempt to scroll an element which is actually scrollable
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.