Skip to content

Commit

Permalink
Leverage delite/FormWidget code to read original name/value settings …
Browse files Browse the repository at this point in the history
…from embedded <input>.

Refs ibm-js/delite#394, refs #584 too.
  • Loading branch information
wkeese committed Sep 10, 2015
1 parent f65c958 commit f153fcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
5 changes: 3 additions & 2 deletions Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ define([

render: register.superCall(function (sup) {
return function () {
this.valueNode = this.querySelector("input") || this.ownerDocument.createElement("input");
sup.call(this);
this.appendChild(this.valueNode);
if (!this.valueNode.parentNode) {
this.appendChild(this.valueNode);
}
this.handleMin.setAttribute("aria-valuemin", this.min);
this.focusNode.setAttribute("aria-valuemax", this.max);
this.tabStops = "handleMin,focusNode";
Expand Down
26 changes: 4 additions & 22 deletions StarRating.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,12 @@ define([

postRender: function () {
this.notifyCurrentValue("disabled", "max", "value", "readOnly", "allowZero");
this.valueNode.style.display = "none";
if (!this.valueNode.parentNode) {
this.appendChild(this.valueNode);
}
},


/**
* Handle setting of the value from the input node, if set it should be used in place of the value attribute.
*/
_mapAttributes: dcl.superCall(function (sup) {
return function () {
var inputs = this.getElementsByTagName("INPUT");
if (inputs.length) {
this.valueNode = inputs[0];
this.valueNode.style.display = "none";
if (!isNaN(parseFloat(this.valueNode.value))) {
this.setAttribute("value", this.valueNode.value);
}
} else {
this.valueNode = this.ownerDocument.createElement("input");
this.valueNode.style.display = "none";
this.appendChild(this.valueNode);
}
return sup.call(this);
};
}),

/* jshint maxcomplexity: 13 */
refreshRendering: function (props) {
if ("disabled" in props) {
Expand Down

0 comments on commit f153fcb

Please sign in to comment.