1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Extend fakedom for KaTeX on Node.js

To make KaTeX work on the server we need to add support for the style
attribute and for setting the textContent of an element.
This commit is contained in:
Jermolene 2014-10-06 21:10:35 +01:00
parent 3630a2191e
commit cbe2a53d6a

View File

@ -39,6 +39,7 @@ var TW_Element = function(tag,namespace) {
this.attributes = {}; this.attributes = {};
this.isRaw = false; this.isRaw = false;
this.children = []; this.children = [];
this.style = {};
this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml"; this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml";
}; };
@ -137,6 +138,13 @@ Object.defineProperty(TW_Element.prototype, "outerHTML", {
} }
} }
} }
if(this.style) {
var style = [];
for(var s in this.style) {
style.push(s + ":" + this.style[s] + ";");
}
output.push(" style='",style.join(""),"'")
}
output.push(">"); output.push(">");
if($tw.config.htmlVoidElements.indexOf(this.tag) === -1) { if($tw.config.htmlVoidElements.indexOf(this.tag) === -1) {
output.push(this.innerHTML); output.push(this.innerHTML);
@ -179,6 +187,9 @@ Object.defineProperty(TW_Element.prototype, "textContent", {
}); });
return b.join(""); return b.join("");
} }
},
set: function(value) {
this.children = [new TW_TextNode(value)];
} }
}); });