Skip to content

Commit

Permalink
fix correct return value of select (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored and danrot committed Mar 15, 2018
1 parent c900994 commit 335f1b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
21 changes: 11 additions & 10 deletions dist/husky.js
Original file line number Diff line number Diff line change
Expand Up @@ -40776,13 +40776,10 @@ define('__component__$select@husky',[], function() {
checkboxVisible = checkboxVisible !== false;
var $item,
template = (this.options.isNative) ? this.template.optionElement : this.template.menuElement,
idString = (id !== null && typeof id !== 'undefined') ? id.toString() : this.sandbox.util.uniqueId(),
originalValue = value;

value = this.sandbox.util.escapeHtml(value);
idString = (id !== null && typeof id !== 'undefined') ? id.toString() : this.sandbox.util.uniqueId();

if (this.options.preSelectedElements.indexOf(idString) >= 0 ||
this.options.preSelectedElements.indexOf(originalValue) >= 0
this.options.preSelectedElements.indexOf(value) >= 0
) {
this.setToolTip(value);
$item = this.sandbox.dom.createElement(this.sandbox.util.template(
Expand Down Expand Up @@ -41471,15 +41468,15 @@ define('__component__$select@husky',[], function() {
changeLabel: function() {
if (this.options.fixedLabel !== true) {
if (this.selectedElements.length === this.options.data.length && this.options.multipleSelect === true) {
this.sandbox.dom.html(this.$label, this.options.checkedAllLabel);
this.sandbox.dom.text(this.$label, this.options.checkedAllLabel);
} else if (this.selectedElements.length === 0) {
this.sandbox.dom.html(this.$label, this.options.defaultLabel);
this.sandbox.dom.text(this.$label, this.options.defaultLabel);
} else {
var text = "";
this.sandbox.util.each(this.selectedElementsValues, function(index, value) {
text += ' ' + value + ',';
});
this.sandbox.dom.html(this.$label, text.substring(1, text.length - 1));
this.sandbox.dom.text(this.$label, text.substring(1, text.length - 1));
}
}
},
Expand Down Expand Up @@ -41572,6 +41569,10 @@ define('__component__$select@husky',[], function() {
iconSpan = '<span class="fa-' + icon + ' icon"></span>';
}

if (defaultLabel) {
defaultLabel = this.sandbox.util.escapeHtml(defaultLabel);
}

if (!!this.options.data && !!this.options.data.length || this.options.editable) {
dropdownStyle = '';
}
Expand Down Expand Up @@ -41621,15 +41622,15 @@ define('__component__$select@husky',[], function() {
' <span class="icon"></span>',
' </div>',
' </div>',
' <div class="item-value">', value, '</div>',
' <div class="item-value">', this.sandbox.util.escapeHtml(value), '</div>',
' </div>',
'</li>'
].join('');
},
optionElement: function(index, value, checked, updateLabel, checkboxVisible) {
return [
'<option <% if (checked) { print("selected "); } %>value="' + index + '">',
value,
this.sandbox.util.escapeHtml(value),
'</option>'
].join('');
}
Expand Down
2 changes: 1 addition & 1 deletion dist/husky.min.js

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions husky_components/select/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,10 @@ define([], function() {
checkboxVisible = checkboxVisible !== false;
var $item,
template = (this.options.isNative) ? this.template.optionElement : this.template.menuElement,
idString = (id !== null && typeof id !== 'undefined') ? id.toString() : this.sandbox.util.uniqueId(),
originalValue = value;

value = this.sandbox.util.escapeHtml(value);
idString = (id !== null && typeof id !== 'undefined') ? id.toString() : this.sandbox.util.uniqueId();

if (this.options.preSelectedElements.indexOf(idString) >= 0 ||
this.options.preSelectedElements.indexOf(originalValue) >= 0
this.options.preSelectedElements.indexOf(value) >= 0
) {
this.setToolTip(value);
$item = this.sandbox.dom.createElement(this.sandbox.util.template(
Expand Down Expand Up @@ -1148,15 +1145,15 @@ define([], function() {
changeLabel: function() {
if (this.options.fixedLabel !== true) {
if (this.selectedElements.length === this.options.data.length && this.options.multipleSelect === true) {
this.sandbox.dom.html(this.$label, this.options.checkedAllLabel);
this.sandbox.dom.text(this.$label, this.options.checkedAllLabel);
} else if (this.selectedElements.length === 0) {
this.sandbox.dom.html(this.$label, this.options.defaultLabel);
this.sandbox.dom.text(this.$label, this.options.defaultLabel);
} else {
var text = "";
this.sandbox.util.each(this.selectedElementsValues, function(index, value) {
text += ' ' + value + ',';
});
this.sandbox.dom.html(this.$label, text.substring(1, text.length - 1));
this.sandbox.dom.text(this.$label, text.substring(1, text.length - 1));
}
}
},
Expand Down Expand Up @@ -1249,6 +1246,10 @@ define([], function() {
iconSpan = '<span class="fa-' + icon + ' icon"></span>';
}

if (defaultLabel) {
defaultLabel = this.sandbox.util.escapeHtml(defaultLabel);
}

if (!!this.options.data && !!this.options.data.length || this.options.editable) {
dropdownStyle = '';
}
Expand Down Expand Up @@ -1298,15 +1299,15 @@ define([], function() {
' <span class="icon"></span>',
' </div>',
' </div>',
' <div class="item-value">', value, '</div>',
' <div class="item-value">', this.sandbox.util.escapeHtml(value), '</div>',
' </div>',
'</li>'
].join('');
},
optionElement: function(index, value, checked, updateLabel, checkboxVisible) {
return [
'<option <% if (checked) { print("selected "); } %>value="' + index + '">',
value,
this.sandbox.util.escapeHtml(value),
'</option>'
].join('');
}
Expand Down

0 comments on commit 335f1b3

Please sign in to comment.