FIX: forces boolean when content is only "true" && "false"

This commit is contained in:
Joffrey JAFFEUX
2018-05-24 23:41:39 +02:00
committed by GitHub
parent 30fbf6fe81
commit 1be76d066c
6 changed files with 45 additions and 4 deletions

View File

@ -27,6 +27,19 @@ export default Ember.Mixin.create({
return !isNaN(parseFloat(input)) && isFinite(input);
},
_cast(value) {
if (value === this.noneValue) return value;
return this._castInteger(this._castBoolean(value));
},
_castBoolean(value) {
if (this.get("castBoolean") && Ember.isPresent(value) && typeof(value) === "string") {
return value === "true";
}
return value;
},
_castInteger(value) {
if (this.get("castInteger") && Ember.isPresent(value) && this._isNumeric(value)) {
return parseInt(value, 10);