diff --git a/core/modules/widgets/radio.js b/core/modules/widgets/radio.js index daa06ae11..90eca6bfd 100644 --- a/core/modules/widgets/radio.js +++ b/core/modules/widgets/radio.js @@ -33,12 +33,15 @@ RadioWidget.prototype.render = function(parent,nextSibling) { this.computeAttributes(); // Execute our logic this.execute(); + var isChecked = this.getValue() === this.radioValue; // Create our elements this.labelDomNode = this.document.createElement("label"); - this.labelDomNode.setAttribute("class",this.radioClass); + this.labelDomNode.setAttribute("class", + "tc-radio " + this.radioClass + (isChecked ? " tc-radio-selected" : "") + ); this.inputDomNode = this.document.createElement("input"); this.inputDomNode.setAttribute("type","radio"); - if(this.getValue() == this.radioValue) { + if(isChecked) { this.inputDomNode.setAttribute("checked","true"); } this.labelDomNode.appendChild(this.inputDomNode); @@ -92,10 +95,6 @@ RadioWidget.prototype.execute = function() { this.radioIndex = this.getAttribute("index"); this.radioValue = this.getAttribute("value"); this.radioClass = this.getAttribute("class",""); - if(this.radioClass !== "") { - this.radioClass += " "; - } - this.radioClass += "tc-radio"; // Make the child widgets this.makeChildWidgets(); }; diff --git a/editions/tw5.com/tiddlers/widgets/RadioWidget.tid b/editions/tw5.com/tiddlers/widgets/RadioWidget.tid index 21b1ca575..347a37e72 100644 --- a/editions/tw5.com/tiddlers/widgets/RadioWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/RadioWidget.tid @@ -1,6 +1,6 @@ caption: radio created: 20131212195353929 -modified: 20161217112444671 +modified: 20170115095809695 tags: Widgets title: RadioWidget type: text/vnd.tiddlywiki @@ -18,7 +18,7 @@ The content of the `<$radio>` widget is displayed within an HTML `