diff --git a/core/modules/commands/rendertiddlers.js b/core/modules/commands/rendertiddlers.js index 20a1d5214..c748d2593 100644 --- a/core/modules/commands/rendertiddlers.js +++ b/core/modules/commands/rendertiddlers.js @@ -42,7 +42,7 @@ Command.prototype.execute = function() { $tw.utils.each(tiddlers,function(title) { var parser = wiki.parseTiddler(template), widgetNode = wiki.makeWidget(parser,{variables: {currentTiddler: title}}); - var container = $tw.document.createElement("div"); + var container = $tw.fakeDocument.createElement("div"); widgetNode.render(container,null); var text = type === "text/html" ? container.innerHTML : container.textContent; fs.writeFileSync(path.resolve(pathname,encodeURIComponent(title) + extension),text,"utf8"); diff --git a/core/modules/parsers/wikiparser/rules/typedblock.js b/core/modules/parsers/wikiparser/rules/typedblock.js index c332441df..561733b91 100644 --- a/core/modules/parsers/wikiparser/rules/typedblock.js +++ b/core/modules/parsers/wikiparser/rules/typedblock.js @@ -66,7 +66,7 @@ exports.parse = function() { } else { // Otherwise, render to the rendertype and return in a
tag var widgetNode = this.parser.wiki.makeWidget(parser), - container = $tw.document.createElement("div"); + container = $tw.fakeDocument.createElement("div"); widgetNode.render(container,null); var text = renderType === "text/html" ? container.innerHTML : container.textContent; return [{ diff --git a/core/modules/startup.js b/core/modules/startup.js index 9ea7e6685..1a97e22c1 100755 --- a/core/modules/startup.js +++ b/core/modules/startup.js @@ -130,8 +130,8 @@ exports.startup = function() { // Set up the styles var styleTemplateTitle = "$:/core/ui/PageStylesheet", styleParser = $tw.wiki.parseTiddler(styleTemplateTitle); - $tw.styleWidgetNode = $tw.wiki.makeWidget(styleParser,{document: $tw.document}); - $tw.styleContainer = $tw.document.createElement("style"); + $tw.styleWidgetNode = $tw.wiki.makeWidget(styleParser,{document: $tw.fakeDocument}); + $tw.styleContainer = $tw.fakeDocument.createElement("style"); $tw.styleWidgetNode.render($tw.styleContainer,null); $tw.styleElement = document.createElement("style"); $tw.styleElement.innerHTML = $tw.styleContainer.textContent; diff --git a/core/modules/utils/fakedom.js b/core/modules/utils/fakedom.js index 126a1b0af..8717f0ee5 100755 --- a/core/modules/utils/fakedom.js +++ b/core/modules/utils/fakedom.js @@ -182,6 +182,6 @@ var document = { }, }; -exports.document = document; +exports.fakeDocument = document; })(); diff --git a/core/modules/wiki.js b/core/modules/wiki.js index a1a6d640e..ab8d01159 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -821,7 +821,7 @@ exports.makeWidget = function(parser,options) { // Create the widget return new widget.widget(widgetNode,{ wiki: this, - document: options.document || $tw.document, + document: options.document || $tw.fakeDocument, parentWidget: options.parentWidget }); }; @@ -840,7 +840,7 @@ exports.renderText = function(outputType,textType,text,options) { options = options || {}; var parser = this.parseText(textType,text,options), widgetNode = this.makeWidget(parser,options); - var container = $tw.document.createElement("div"); + var container = $tw.fakeDocument.createElement("div"); widgetNode.render(container,null); return outputType === "text/html" ? container.innerHTML : container.textContent; }; @@ -858,7 +858,7 @@ exports.renderTiddler = function(outputType,title,options) { options = options || {}; var parser = this.parseTiddler(title), widgetNode = this.makeWidget(parser,options); - var container = $tw.document.createElement("div"); + var container = $tw.fakeDocument.createElement("div"); widgetNode.render(container,null); return outputType === "text/html" ? container.innerHTML : container.textContent; }; diff --git a/editions/test/tiddlers/tests/test-widget.js b/editions/test/tiddlers/tests/test-widget.js index 03b3465b6..2b42ed005 100755 --- a/editions/test/tiddlers/tests/test-widget.js +++ b/editions/test/tiddlers/tests/test-widget.js @@ -19,7 +19,7 @@ describe("Widget module", function() { function createWidgetNode(parseTreeNode,wiki) { return new widget.widget(parseTreeNode,{ wiki: wiki, - document: $tw.document + document: $tw.fakeDocument }); } @@ -29,8 +29,8 @@ describe("Widget module", function() { } function renderWidgetNode(widgetNode) { - $tw.document.setSequenceNumber(0); - var wrapper = $tw.document.createElement("div"); + $tw.fakeDocument.setSequenceNumber(0); + var wrapper = $tw.fakeDocument.createElement("div"); widgetNode.render(wrapper,null); // console.log(require("util").inspect(wrapper,{depth: 8})); return wrapper; diff --git a/editions/tw5.com/tiddlers/moduletypes/WidgetModules.tid b/editions/tw5.com/tiddlers/moduletypes/WidgetModules.tid index 65aa16169..1a8bf5edf 100644 --- a/editions/tw5.com/tiddlers/moduletypes/WidgetModules.tid +++ b/editions/tw5.com/tiddlers/moduletypes/WidgetModules.tid @@ -22,7 +22,7 @@ The following widget properties are defined by the core. The lifecycle of a widg |''wiki'' |Reference to the [[Wiki]] object associated with this widget | |''variables'' |Hashmap of information about each [[widget variable|WidgetVariables]] (see below) | |''parentWidget'' |Reference to the parent widget | -|''document'' |Reference to the document object associated with this widget. Usually either the browser global `document` variable or a reference to the FakeDomMechanism's `$tw.document` | +|''document'' |Reference to the document object associated with this widget. Usually either the browser global `document` variable or a reference to the FakeDomMechanism's `$tw.fakeDocument` | |''attributes'' |Hashmap of information about each attribute attached to this widget (see below) | |''children'' |Array of child widgets | |''domNodes'' |For widgets that directly generate DOM nodes, an array of the generated nodes |