Wrong error log for "offsetParent is not set -- cannot scroll"
See original GitHub issueConfiguration:
- Web browser and its version: Chrome (but applies to all)
- Operating system and its version: Any
- PDF.js version: pdfjs-dist v2.0.943
- Is a browser extension: No
Steps to reproduce the problem: Imagine (e.g. an angular) application with tabs where only the currently visible tab is attached to the DOM tree. When you want to display a large PDF and switching the tab (which will disconnect the current tab from DOM tree) it logs an error.
I am just wondering about the following code:
function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
// Assuming offsetParent is available (it's not available when viewer is in
// hidden iframe or object). We have to scroll: if the offsetParent is not set
// producing the error. See also animationStarted.
let parent = element.offsetParent;
if (!parent) {
console.error('offsetParent is not set -- cannot scroll');
return;
}
Why is this logging an error? Imho if element.isConnected === false it should be ok since the view is not visible nor attached to the DOM tree.
What is the expected behavior? (add screenshot)
No error log. It should just ignore it.
What went wrong? (add screenshot)
An error is shwon in debug console.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
offsetParent.scrollTop doesn't work in most browsers
I've tried a while loop and continuously getting parentElement until x.style.overflow="scroll" , but that didn't work. – Stijn Sanders. Dec 21, ...
Read more >offsetParent is not set -- cannot scroll - Firefox - MSDN
I get error to show PDF:(console log) offsetParent is not set -- cannot scroll PDF c21f21ea44c1e2ed2581435fa5a2dcce [1.6 Acrobat Distiller ...
Read more >Troubleshooting
No PDF file shown - error message "offsetParent not set - cannot scroll" in the console. This error means that the PDF viewer...
Read more >1580661 - Update pdf.js to version 2.3.164
#11129 Prevent "offsetParent is not set -- cannot scroll" errors when the viewer loads in e.g. a hidden <iframe> #11133 Enable the no-async-promise-executor ......
Read more >Interacting with Elements
Scroll the page if still covered by an element with fixed position. ... You will usually get an error explaining why the element...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since PDF.js was written primarily for use in Firefox, rather than for use with particular JS frameworks, I fail to see the need for any changes here especially since this isn’t a breaking error. Furthermore, having a notification about
scrollIntoView
not attempting to do any scrolling may also be useful in some cases. My suggestion would be WONTFIX, or INVALID, as the appropriate resolution here.If I understood Snuffleupagus correctly, this error log message should be changed to a warning.