mirror of
https://github.com/discourse/discourse.git
synced 2025-04-27 04:54:30 +08:00
FIX: Couldn't select values of 0 in the combo-box
This commit is contained in:
parent
5ebd12c070
commit
7ef83913b6
@ -32,7 +32,8 @@ export default Ember.Component.extend({
|
|||||||
if (this.get('content')) {
|
if (this.get('content')) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.get('content').forEach(function(o) {
|
this.get('content').forEach(function(o) {
|
||||||
let val = o[self.get('valueAttribute')] || o;
|
let val = o[self.get('valueAttribute')];
|
||||||
|
if (typeof val === "undefined") { val = o; }
|
||||||
if (!Em.isNone(val)) { val = val.toString(); }
|
if (!Em.isNone(val)) { val = val.toString(); }
|
||||||
|
|
||||||
const selectedText = (val === selected) ? "selected" : "";
|
const selectedText = (val === selected) ? "selected" : "";
|
||||||
|
@ -15,6 +15,19 @@ componentTest('with objects', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentTest('with objects and valueAttribute', {
|
||||||
|
template: '{{combo-box content=items valueAttribute="value"}}',
|
||||||
|
setup() {
|
||||||
|
this.set('items', [{value: 0, name: 'hello'}, {value: 1, name: 'world'}]);
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.ok(this.$('.combobox').length);
|
||||||
|
assert.equal(this.$("select option[value='0']").text(), 'hello');
|
||||||
|
assert.equal(this.$("select option[value='1']").text(), 'world');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
componentTest('with an array', {
|
componentTest('with an array', {
|
||||||
template: '{{combo-box content=items value=value}}',
|
template: '{{combo-box content=items value=value}}',
|
||||||
setup() {
|
setup() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user