Turns out it wasn't a race condition, the code to render was just never called. I just published a new version that throws an error when no headings are found
Nitpick: Looks like the condition for the if-block starting with "if (currentHeadings.length !== previousHeadings.length" can be inverted, allowing for another early return and a lowered indentation level for the remaining function body.
Thanks for the bug report, I need to spend a little time cleaning this up (it's slightly more broken on Safari too), and that's a good idea on the early return.
I can't think of a hack to make anchors work. In theory we could poll for the element and scroll it into view once it becomes available, but we'd have to abort the polling if the user scrolls. And we can't detect scroll events in the parent frame. :(
I removed the anchor hash, and it's working in FF and Chrome again (Safari never worked, and I can't work around it unfortunately). I think the only way to truly fix these fully is to get better support in the parent code to do something with this...I'll noodle on it.
toc() requires title to be a string, but does not actually escape it (e.g. "The <foo> element"). I'd recommend to pass strings through DOM.text(), and alternatively allow an Element instance to be passed in (in which case it shouldn't get wrapped in <b>).