question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong error log for "offsetParent is not set -- cannot scroll"

See original GitHub issue

Configuration:

  • 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Snuffleupaguscommented, Dec 21, 2018

Perhaps @Snuffleupagus can chime in if you have ideas about this?

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.

0reactions
Bluejaniscommented, Dec 5, 2019

If I understood Snuffleupagus correctly, this error log message should be changed to a warning.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found