Ignite properties now try to keep the value as the same type as the original when a new value is set. Support for value() on contenteditable was added along with reflecting contenteditable values.

This commit is contained in:
2020-10-26 15:30:11 -07:00
parent c172cb5599
commit 3bee5614ab
2 changed files with 201 additions and 143 deletions

View File

@ -40,7 +40,21 @@ class IgniteProperty {
return;
}
//Get the old value
var old = this._value;
//Based on the old value, see if we need to convert the new value to match the original type.
if (typeof old === typeof true) {
val = val != null && val != undefined ? val.toString().toLowerCase().trim() : val;
val = val == "true" || val == "1" || val == "yes" || val == "t" || val == "y";
} else if (typeof old === typeof 0) {
val = Number(val != null && val != undefined ? val.toString().trim() : "0");
val = isNaN(val) ? 0 : val;
} else if (typeof old === typeof "") {
val = val != null && val != undefined ? val.toString() : null;
}
//Set the new value
this._value = val;
//Attempt to patch the value if it's an array.