From df59dee1889580b2e5e193be2fb33c3928cc136b Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 17 Jan 2013 11:28:24 +0000 Subject: [PATCH] Removed ability for widgets to not generate any elements It interfered with the refresh mechanism --- core/modules/rendertree/renderers/element.js | 76 +++++++++----------- core/modules/widgets/view/viewers/link.js | 5 +- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/core/modules/rendertree/renderers/element.js b/core/modules/rendertree/renderers/element.js index fff745e7c..00f17dc61 100644 --- a/core/modules/rendertree/renderers/element.js +++ b/core/modules/rendertree/renderers/element.js @@ -114,54 +114,48 @@ ElementRenderer.prototype.getAttribute = function(name,defaultValue) { }; ElementRenderer.prototype.render = function(type) { - // Check if our widget is providing an element - if(this.widget.tag) { - var isHtml = type === "text/html", - output = [],attr,a,v; - if(isHtml) { - output.push("<",this.widget.tag); - if(this.widget.attributes) { - attr = []; - for(a in this.widget.attributes) { - attr.push(a); - } - attr.sort(); - for(a=0; a"); } - 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(""); - } + if(!this.widget.children || this.widget.children.length === 0) { + output.push("/"); } - return output.join(""); - } else { - // Just render our first child if we're not generating an element - return this.widget.children[0].render(type); + output.push(">"); } + 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(""); + } + } + return output.join(""); }; ElementRenderer.prototype.renderInDom = function() { diff --git a/core/modules/widgets/view/viewers/link.js b/core/modules/widgets/view/viewers/link.js index 14c92add7..93e84b5f8 100644 --- a/core/modules/widgets/view/viewers/link.js +++ b/core/modules/widgets/view/viewers/link.js @@ -22,7 +22,10 @@ var LinkViewer = function(viewWidget,tiddler,field,value) { LinkViewer.prototype.render = function() { var text = this.value === undefined ? "" : this.value; // 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,[{ type: "element", tag: "$link",