"document not defined" error while rendering

28 views
Skip to first unread message

Riz

unread,
Jun 2, 2020, 6:54:58 AM6/2/20
to TiddlyWikiDev
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?

Riz

unread,
Jun 2, 2020, 7:09:17 AM6/2/20
to TiddlyWikiDev
Nevermind. Solved it by using $tw.fakeDocument
Reply all
Reply to author
Forward
0 new messages