mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 18:00:26 +00:00
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:
parent
839361d54f
commit
2c790d982f
@ -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");
|
||||
|
@ -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 [{
|
||||
|
@ -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;
|
||||
|
@ -182,6 +182,6 @@ var document = {
|
||||
},
|
||||
};
|
||||
|
||||
exports.document = document;
|
||||
exports.fakeDocument = document;
|
||||
|
||||
})();
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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 |
|
||||
|
Loading…
Reference in New Issue
Block a user