I wrote a simple js macro. It create a few DOM elements and returns the outerHTML as a string. This works perfectly in TW5. However when I try to render a tiddler containing a call to said macro, tw5 gives me the error "document is not defined". I did some googling and found out that document variable is defined after window finishes loading. So my hypothesis is since render command is essentially headless, document remains undefined.
So questions:
1. Is my hypothesis correct?
2. Is there a way to circumvent it?