mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-30 09:28:01 +00:00
Removed ability for widgets to not generate any elements
It interfered with the refresh mechanism
This commit is contained in:
@@ -114,54 +114,48 @@ ElementRenderer.prototype.getAttribute = function(name,defaultValue) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ElementRenderer.prototype.render = function(type) {
|
ElementRenderer.prototype.render = function(type) {
|
||||||
// Check if our widget is providing an element
|
var isHtml = type === "text/html",
|
||||||
if(this.widget.tag) {
|
output = [],attr,a,v;
|
||||||
var isHtml = type === "text/html",
|
if(isHtml) {
|
||||||
output = [],attr,a,v;
|
output.push("<",this.widget.tag);
|
||||||
if(isHtml) {
|
if(this.widget.attributes) {
|
||||||
output.push("<",this.widget.tag);
|
attr = [];
|
||||||
if(this.widget.attributes) {
|
for(a in this.widget.attributes) {
|
||||||
attr = [];
|
attr.push(a);
|
||||||
for(a in this.widget.attributes) {
|
}
|
||||||
attr.push(a);
|
attr.sort();
|
||||||
}
|
for(a=0; a<attr.length; a++) {
|
||||||
attr.sort();
|
v = this.widget.attributes[attr[a]];
|
||||||
for(a=0; a<attr.length; a++) {
|
if(v !== undefined) {
|
||||||
v = this.widget.attributes[attr[a]];
|
if($tw.utils.isArray(v)) {
|
||||||
if(v !== undefined) {
|
v = v.join(" ");
|
||||||
if($tw.utils.isArray(v)) {
|
} else if(typeof v === "object") {
|
||||||
v = v.join(" ");
|
var s = [];
|
||||||
} else if(typeof v === "object") {
|
for(var p in v) {
|
||||||
var s = [];
|
s.push(p + ":" + v[p] + ";");
|
||||||
for(var p in v) {
|
|
||||||
s.push(p + ":" + v[p] + ";");
|
|
||||||
}
|
|
||||||
v = s.join("");
|
|
||||||
}
|
}
|
||||||
output.push(" ",attr[a],"='",$tw.utils.htmlEncode(v),"'");
|
v = s.join("");
|
||||||
}
|
}
|
||||||
|
output.push(" ",attr[a],"='",$tw.utils.htmlEncode(v),"'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!this.widget.children || this.widget.children.length === 0) {
|
|
||||||
output.push("/");
|
|
||||||
}
|
|
||||||
output.push(">");
|
|
||||||
}
|
}
|
||||||
if(this.widget.children && this.widget.children.length > 0) {
|
if(!this.widget.children || this.widget.children.length === 0) {
|
||||||
$tw.utils.each(this.widget.children,function(node) {
|
output.push("/");
|
||||||
if(node.render) {
|
|
||||||
output.push(node.render(type));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(isHtml) {
|
|
||||||
output.push("</",this.widget.tag,">");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return output.join("");
|
output.push(">");
|
||||||
} else {
|
|
||||||
// Just render our first child if we're not generating an element
|
|
||||||
return this.widget.children[0].render(type);
|
|
||||||
}
|
}
|
||||||
|
if(this.widget.children && this.widget.children.length > 0) {
|
||||||
|
$tw.utils.each(this.widget.children,function(node) {
|
||||||
|
if(node.render) {
|
||||||
|
output.push(node.render(type));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(isHtml) {
|
||||||
|
output.push("</",this.widget.tag,">");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output.join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
ElementRenderer.prototype.renderInDom = function() {
|
ElementRenderer.prototype.renderInDom = function() {
|
||||||
|
@@ -22,7 +22,10 @@ var LinkViewer = function(viewWidget,tiddler,field,value) {
|
|||||||
LinkViewer.prototype.render = function() {
|
LinkViewer.prototype.render = function() {
|
||||||
var text = this.value === undefined ? "" : this.value;
|
var text = this.value === undefined ? "" : this.value;
|
||||||
// Indicate that we're not generating an element
|
// Indicate that we're not generating an element
|
||||||
this.viewWidget.tag = undefined;
|
this.viewWidget.tag = this.viewWidget.renderer.parseTreeNode.isBlock ? "div" : "span";
|
||||||
|
this.viewWidget.attributes = {
|
||||||
|
"class": "tw-view-link"
|
||||||
|
};
|
||||||
this.viewWidget.children = this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer.renderContext,[{
|
this.viewWidget.children = this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer.renderContext,[{
|
||||||
type: "element",
|
type: "element",
|
||||||
tag: "$link",
|
tag: "$link",
|
||||||
|
Reference in New Issue
Block a user