Medium Feed

 

Tuesday, August 23, 2022

ShadowDOM and rootDOM - Calculate the DOM max depth and width

An automated way to find the depth and width of shadowDOM/RootDOM


                                Find depth & width of shadowDOM / RootDOM
                        

Heey Heeey stop stop stop !!!. What is DOM Depth( should I measure in cm?? ) what is DOM Width( does DOM gains weight ? )

The Shadow DOM allows hidden trees to be attached in the regular DOM tree. it starts with a shadow root, underneath we can have any number of element.

console.log(getDomStatus(document.body, true));// Includes shadowDOMThe sample result will be :
sample result from above function.