Skip to content

Adding support to -Infinity #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shells/dev/target/Target.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default {
items: [1, 2],
regex: /(a\w+b)/g,
nan: NaN,
infinity: Infinity
infinity: Infinity,
negativeInfinity: -Infinity
}
},
computed: {
Expand Down
4 changes: 4 additions & 0 deletions src/devtools/components/DataField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import {
UNDEFINED,
INFINITY,
NEGATIVE_INFINITY,
NAN,
isPlainObject,
sortByKey
Expand Down Expand Up @@ -78,6 +79,7 @@ export default {
type === 'boolean' ||
type === 'number' ||
value === INFINITY ||
value === NEGATIVE_INFINITY ||
value === NAN
) {
return 'literal'
Expand All @@ -101,6 +103,8 @@ export default {
return 'NaN'
} else if (value === INFINITY) {
return 'Infinity'
} else if (value === NEGATIVE_INFINITY) {
return '-Infinity'
} else if (Array.isArray(value)) {
return 'Array[' + value.length + ']'
} else if (isPlainObject(value)) {
Expand Down
5 changes: 5 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function inDoc (node) {

export const UNDEFINED = '__vue_devtool_undefined__'
export const INFINITY = '__vue_devtool_infinity__'
export const NEGATIVE_INFINITY = '__vue_devtool_negative_infinity__'
export const NAN = '__vue_devtool_nan__'

export function stringify (data) {
Expand All @@ -48,6 +49,8 @@ function replacer (key, val) {
return UNDEFINED
} else if (val === Infinity) {
return INFINITY
} else if (val === -Infinity) {
return NEGATIVE_INFINITY
} else if (Number.isNaN(val)) {
return NAN
} else if (val instanceof RegExp) {
Expand All @@ -69,6 +72,8 @@ function reviver (key, val) {
return undefined
} else if (val === INFINITY) {
return Infinity
} else if (val === NEGATIVE_INFINITY) {
return -Infinity
} else if (val === NAN) {
return NaN
} else {
Expand Down
3 changes: 2 additions & 1 deletion test/specs/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ module.exports = {
.assert.containsText('.data-el.props .data-field:nth-child(2)', 'msg:\n"hi"')
.assert.containsText('.data-el.props .data-field:nth-child(3)', 'obj:\nundefined')
// Regexp
.assert.containsText('.data-el.data .data-field:nth-child(5)', 'regex:/(a\\w+b)/g')
.assert.containsText('.data-el.data .data-field:nth-child(6)', 'regex:/(a\\w+b)/g')
// Literals
.assert.containsText('.data-el.data .data-field:nth-child(4)', 'NaN')
.assert.containsText('.data-el.data .data-field:nth-child(1)', 'Infinity')
.assert.containsText('.data-el.data .data-field:nth-child(5)', '-Infinity')

// expand child instance
.click('.instance .instance:nth-child(2) .arrow-wrapper')
Expand Down