Skip to content
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

Check for null argument while bailing out #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

udayanshevade
Copy link

@udayanshevade udayanshevade commented Sep 2, 2020

Regarding #161: Adding a couple of quick checks wherever the original scroll functions are called to ensure properties on arguments[0] aren't accessed if its value is null, after shouldBailOut(arguments[0]) evaluates to true.

? arguments[0].left
: typeof arguments[0] !== 'object'
: arguments[0] === null || typeof arguments[0] !== 'object'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: Checking against null and allowing it to be passed through to the original scroll function. If this isn't desirable I can revert it.

? arguments[0].left
: typeof arguments[0] !== 'object'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the browser implementation of window.scrollTo handles null, whereas this ternary excludes null and passes a default of scrollX or pageXOffset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant