Skip to content

Commit de61e06

Browse files
committed
fix Infinity display in inspector
1 parent 7b69134 commit de61e06

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/devtools/components/DataField.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</template>
3838

3939
<script>
40-
import { UNDEFINED, isPlainObject } from '../../util'
40+
import { UNDEFINED, INFINITY, isPlainObject } from '../../util'
4141
4242
const rawTypeRE = /^\[object (\w+)\]$/
4343
@@ -59,13 +59,13 @@ export default {
5959
const type = typeof value
6060
if (value == null || value === UNDEFINED) {
6161
return 'null'
62+
} else if (type === 'boolean' || type === 'number' || value === INFINITY) {
63+
return 'literal'
6264
} else if (
6365
value instanceof RegExp ||
6466
(type === 'string' && !rawTypeRE.test(value))
6567
) {
6668
return 'string'
67-
} else if (type === 'boolean' || type === 'number') {
68-
return 'literal'
6969
}
7070
},
7171
isExpandableType () {
@@ -78,6 +78,8 @@ export default {
7878
return 'null'
7979
} else if (value === UNDEFINED) {
8080
return 'undefined'
81+
} else if (value === INFINITY) {
82+
return 'Infinity'
8183
} else if (Array.isArray(value)) {
8284
return 'Array[' + value.length + ']'
8385
} else if (isPlainObject(value)) {

src/util.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function inDoc (node) {
3636
*/
3737

3838
export const UNDEFINED = '__vue_devtool_undefined__'
39+
export const INFINITY = '__vue_devtool_infinity__'
3940

4041
export function stringify (data) {
4142
return CircularJSON.stringify(data, replacer)
@@ -44,13 +45,15 @@ export function stringify (data) {
4445
function replacer (key, val) {
4546
if (val === undefined) {
4647
return UNDEFINED
48+
} else if (val === Infinity) {
49+
return INFINITY
4750
} else {
4851
return sanitize(val)
4952
}
5053
}
5154

52-
export function parse (data) {
53-
return CircularJSON.parse(data)
55+
export function parse (data, revivier) {
56+
return CircularJSON.parse(data, revivier)
5457
}
5558

5659
/**

0 commit comments

Comments
 (0)