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

Fix scrollLeft/scrollTop warning in latest Chrome #643

Merged
merged 1 commit into from Jan 6, 2014

Conversation

sophiebits
Copy link
Collaborator

Chrome gives the warnings

body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode.
body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode.

the first time getUnboundedScrollPosition is invoked. This fixes it. (All modern browsers support pageYOffset; IE 8 doesn't but works properly with document.documentElement.scrollTop except in quirks mode which React doesn't support.)

cc @yungsters (by the way, it looks like getDocumentScrollElement can be implemented by checking document.documentElement.clientWidth > 0. but do you need getDocumentScrollElement at all in FB code? it should return document.body only in quirks mode.)

Chrome gives the warnings

```
body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode.
body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode.
```

the first time getUnboundedScrollPosition is invoked. This fixes it. (All modern browsers support `pageYOffset`; IE 8 doesn't but works properly with `document.documentElement.scrollTop` except in quirks mode which React doesn't support.)
@vjeux
Copy link
Contributor

vjeux commented Dec 28, 2013

Who should review this code?

@sophiebits
Copy link
Collaborator Author

Perhaps yungsters or you could do a blame on getUnboundedScrollPosition.js internally.

@ghost ghost assigned yungsters Dec 31, 2013
@yungsters
Copy link
Contributor

I think previous versions of WebKit (and Chrome) returned document.body. Internally, we use getDocumentScrollElement for other reasons besides querying scroll position (e.g. comparing scrollParent), so it's still necessary.

I've tested this on Safari, Firefox, Chrome, and IE 8+. Looks good to me, thanks for investigating and fixing.

yungsters added a commit that referenced this pull request Jan 6, 2014
Fix scrollLeft/scrollTop warning in latest Chrome
@yungsters yungsters merged commit 13230a3 into facebook:master Jan 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants