Does the ResizeObserver fire first when the page loads?
P粉743288436
P粉743288436 2024-03-25 20:48:53
0
1
410

It seems that when I pass the node to ResizeObserver.observe() on the DOMContentLoaded event, it is called immediately. Is this considered normal behavior?

P粉743288436
P粉743288436

reply all(1)
P粉541796322

Yes, this behavior complies with the specification. They do have this comment: p>

So, in your case, either the element isn't in the DOM yet and case 1 will make it fire, or the element is already there and case 5 will (although in "DOMContentLoaded" it should be 5 ;).

But according to the actual specification, observation should be triggered first no matter what. We can note that Chrome did change its behavior recently in CRBUG 1128016 as before this change they were not initially firing on hidden elements.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template