i started to learm javascript and i am creating a navigation component in svelte and needed to add some sort of css visualisation when there is a dropdown multi lvl deep. so i can see wich parents nodes are connected with my "current-item" css class.
the visualisation i use for this project is a color.
i came up with this logic:
https://codepen.io/Digi4Care/pen/YzaJbdW
The logic i use to determin when i reach the beginning of the node:
"LI" == node?.parentNode?.parentNode?.parentNode?.nodeName
I am wondering if there is another and efficienter way to do this?