widgets: resolveProp: preserve numbers and booleans as strings in object values
This commit is contained in:
parent
4c008099ca
commit
c59c4a8065
3 changed files with 16 additions and 4 deletions
|
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## 1.30.2
|
||||
|
||||
- bug fixes
|
||||
- when using objects in properties, numbers-as-strings and booleans-as-strings values are now preserved instead of being converted to their litteral counterparts
|
||||
|
||||
## 1.30.1
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "open-stage-control",
|
||||
"productName": "Open Stage Control",
|
||||
"description": "Libre and modular OSC / MIDI controller",
|
||||
"version": "1.30.1",
|
||||
"version": "1.30.2",
|
||||
"author": {
|
||||
"name": "Jean-Emmanuel Doucet",
|
||||
"email": "jean-emmanuel@ammd.net"
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context) {
|
||||
resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context, recursive) {
|
||||
|
||||
propValue = propValue !== undefined ? propValue : deepCopy(this.props[propName])
|
||||
originalWidget = originalWidget || this
|
||||
|
|
@ -886,7 +886,14 @@ class Widget extends EventEmitter {
|
|||
propValue = propValue.replace(new RegExp(k, 'g'), v)
|
||||
}
|
||||
|
||||
if (isJSON(propValue) && (propName !== 'label' || propValue === 'false')) {
|
||||
if (
|
||||
// json heuristic
|
||||
isJSON(propValue) &&
|
||||
// allow "false" string in label
|
||||
(propName !== 'label' || propValue === 'false') &&
|
||||
// don't coerce booleans and numbers as strings in objects
|
||||
(!recursive || (isNaN(propValue) && propValue != 'true' && propValue != 'false'))
|
||||
) {
|
||||
try {
|
||||
propValue = JSON.parse(propValue)
|
||||
} catch (err) {}
|
||||
|
|
@ -894,7 +901,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
} else if (propValue != null && typeof propValue == 'object') {
|
||||
for (let k in propValue) {
|
||||
propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context)
|
||||
propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue