The second the browser hits that
<table-of-contents>
component, the JavaScript for it executes. It does this before it’s even loaded the child elements inside the component.
I’ve run into this at least once before, and I’m sure this is a better solution than whatever hack I implemented at the time.
(via Jeremy Keith)