Reverted solution for #794 due to undesirable side effects
This commit is contained in:
parent
587db80d21
commit
a60a1125ea
|
@ -3,12 +3,6 @@
|
|||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
|
||||
## not yet published, version 7.0.5
|
||||
|
||||
- Fix #794: fix discrepancy between valid JSON numbers and valid JavaScript
|
||||
numbers (i.e. `+2` is a valid in JavaScript but not in JSON).
|
||||
|
||||
|
||||
## 2019-09-11, version 7.0.4
|
||||
|
||||
- Fixed #723: schema error popup and color picker not always fully visible.
|
||||
|
|
|
@ -1345,14 +1345,10 @@ export function parseString (str) {
|
|||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
// will nicely fail for strings like '123ab', ' ', and '+1'
|
||||
const num = JSON.parse(str)
|
||||
if (typeof num === 'number' && !isNaN(num)) {
|
||||
return num
|
||||
}
|
||||
} catch (err) {
|
||||
// no need to handle this error, it was just to try parsing into a number
|
||||
const num = Number(str) // will nicely fail with '123ab'
|
||||
const numFloat = parseFloat(str) // will nicely fail with ' '
|
||||
if (!isNaN(num) && !isNaN(numFloat)) {
|
||||
return num
|
||||
}
|
||||
|
||||
return str
|
||||
|
|
|
@ -399,7 +399,7 @@ describe('util', () => {
|
|||
assert.strictEqual(parseString('null'), null)
|
||||
assert.strictEqual(parseString('true'), true)
|
||||
assert.strictEqual(parseString('false'), false)
|
||||
assert.strictEqual(parseString('+1'), '+1')
|
||||
assert.strictEqual(parseString('+1'), 1)
|
||||
assert.strictEqual(parseString(' '), ' ')
|
||||
assert.strictEqual(parseString(''), '')
|
||||
assert.strictEqual(parseString('"foo"'), '"foo"')
|
||||
|
|
Loading…
Reference in New Issue