-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Show Set and Map expanded views #490
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
Changes from 4 commits
351cd8a
d7ee05b
be63c3e
ff7f677
db270b3
0c1051f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ import { | |
INFINITY, | ||
NAN, | ||
isPlainObject, | ||
isMap, | ||
isSet, | ||
sortByKey | ||
} from 'src/util' | ||
|
||
|
@@ -89,22 +91,27 @@ export default { | |
}, | ||
isExpandableType () { | ||
const value = this.field.value | ||
return Array.isArray(value) || isPlainObject(value) | ||
return Array.isArray(value) || isPlainObject(value) || | ||
isSet(value) || isMap(value) | ||
}, | ||
formattedValue () { | ||
const value = this.field.value | ||
if (value === null) { | ||
return 'null' | ||
} else if (value === UNDEFINED) { | ||
} else if (value === UNDEFINED || value === undefined) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See below, data shouldn't be revived on devtools side.) |
||
return 'undefined' | ||
} else if (value === NAN) { | ||
} else if (value === NAN || Number.isNaN(value)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Same) |
||
return 'NaN' | ||
} else if (value === INFINITY) { | ||
} else if (value === INFINITY || value === Number.POSITIVE_INFINITY) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Same) |
||
return 'Infinity' | ||
} else if (Array.isArray(value)) { | ||
return 'Array[' + value.length + ']' | ||
} else if (isPlainObject(value)) { | ||
return 'Object' + (Object.keys(value).length ? '' : ' (empty)') | ||
return 'Object[' + Object.keys(value).length + ']' | ||
} else if (isSet(value)) { | ||
return 'Set[' + value.size + ']' | ||
} else if (isMap(value)) { | ||
return 'Map[' + value.size + ']' | ||
} else if (this.valueType === 'native') { | ||
return specialTypeRE.exec(value)[1] | ||
} else if (typeof value === 'string') { | ||
|
@@ -125,11 +132,15 @@ export default { | |
key: i, | ||
value: item | ||
})) | ||
} else if (typeof value === 'object') { | ||
} else if (isPlainObject(value)) { | ||
value = sortByKey(Object.keys(value).map(key => ({ | ||
key, | ||
value: value[key] | ||
}))) | ||
} else if (isSet(value)) { | ||
value = Array.from(value.values()).map(v => ({ key: '_', value: v })) | ||
} else if (isMap(value)) { | ||
value = Array.from(value.entries()).map(([k, v]) => ({ key: k, value: v })) | ||
} | ||
return value | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ function initApp (shell) { | |
}) | ||
|
||
bridge.on('instance-details', details => { | ||
store.commit('components/RECEIVE_INSTANCE_DETAILS', parse(details)) | ||
store.commit('components/RECEIVE_INSTANCE_DETAILS', parse(details, true)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't revive data on devtools side. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Objects, Arrays, Numbers, Strings, and null are already revived on master. Is there any reason we don't want to do this for Sets, Maps, INF, undefined, and NaN? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only revive JSON-compatible data (which means no 'reviving', just like a standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the upcoming State edition system expects JSON-compatible data to work (even if the user doesn't send any change). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that makes sense. I've moved the set reconstruction logic into the component, so the store should only contain JSON-compatible data now. |
||
}) | ||
|
||
bridge.on('vuex:init', snapshot => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try to put a Set inside a Map and the other way around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; I've added a more complex test case in db270b3.