Switch to using `$tw.fakeDocument` for the fakedom document object

So that we can free us `$tw.document` to be the actual DOM document
This commit is contained in:
Jermolene 2014-01-15 14:57:35 +00:00
parent 839361d54f
commit 2c790d982f
7 changed files with 12 additions and 12 deletions

View File

@ -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");

View File

@ -66,7 +66,7 @@ exports.parse = function() {
} else {
// Otherwise, render to the rendertype and return in a <PRE> 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 [{

View File

@ -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;

View File

@ -182,6 +182,6 @@ var document = {
},
};
exports.document = document;
exports.fakeDocument = document;
})();

View File

@ -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;
};

View File

@ -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;

View File

@ -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 |