fix: fix a bug when parsing attributes if no parseHTML method is provided, fix #2058
This commit is contained in:
@@ -3,7 +3,7 @@ export default function fromString(value: any): any {
|
||||
return value
|
||||
}
|
||||
|
||||
if (value.match(/^\d*(\.\d+)?$/)) {
|
||||
if (value.match(/^[+-]?(?:\d*\.)?\d+$/)) {
|
||||
return Number(value)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,12 @@ describe('fromString', () => {
|
||||
expect(value).to.eq('test')
|
||||
})
|
||||
|
||||
it('should return an empty string', () => {
|
||||
const value = fromString('')
|
||||
|
||||
expect(value).to.eq('')
|
||||
})
|
||||
|
||||
it('should convert to a number', () => {
|
||||
const value = fromString('1')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user