Chrome Bug - window.scroll method intercepts DOM rendering

First, play with the navigation menu on this page (left): http://bestds.com/TankStorage/

I use javascipt to update the dom backgroundColor of these li elements on click.

Firefox displays updated DOM elements, but Chrom and Chromium do not display them.

Using the Chromium document inspector, I can clearly see that the background color of the li element has been updated correctly, but they are not displayed. Funny, this will go on and visualize the DOM changes after I place my cursor over the unrendered html element in the Chrom document inspector!

How do I fix this?

+1
source share
1 answer

I get it. Chrom has a rendering error.

If you call the window scroll function, immediately after updating some DOM properties, Chrom will not fully display all your DOM changes.

To fix the problem, I will replace this line:

window.scroll(0,docPos);

Using this line:

setTimeout('window.scroll(0,' + docPos + ')',1);

This gives Chrom the ability to visualize dom changes before a window scrolling error can stop it.

+1
source

Source: https://habr.com/ru/post/1532277/


All Articles