resolve-props: avoid json parse using simple heuristic (big perf hit in widget init)
This commit is contained in:
parent
d7be252b79
commit
8395067565
1 changed files with 7 additions and 3 deletions
|
|
@ -489,9 +489,13 @@ class Widget extends EventEmitter {
|
|||
propValue = propValue.replace(new RegExp(k, 'g'), v)
|
||||
}
|
||||
|
||||
try {
|
||||
propValue = JSON.parse(propValue)
|
||||
} catch (err) {}
|
||||
// heuristic to avoid using JSON when unnecessary
|
||||
// if the string starts with one of these chars it's going to fail
|
||||
if ('/@#.'.indexOf(propValue[0]) === -1) {
|
||||
try {
|
||||
propValue = JSON.parse(propValue)
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
} else if (propValue != null && typeof propValue == 'object') {
|
||||
for (let k in propValue) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue