Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions packages/devtools-kit/__tests__/component/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ describe('format: displayText and rawValue can be calculated by formatInspectorS
})
})

it('type: string value "undefined" should be treated as a string, not null', () => {
// https://github.com/vuejs/devtools/issues/1087
const value = 'undefined'
const displayText = format.formatInspectorStateValue(value)
const rawValue = format.getRaw(value).value

expect(displayText).toBe('undefined')
expect(rawValue).toBe('undefined')
expect(format.getInspectorStateValueType(value)).toBe('string')
})

it('type: plain object', () => {
const value = { foo: 'bar' }
const displayText = format.formatInspectorStateValue(value)
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-kit/src/core/component/state/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { escape, internalStateTokenToString, replaceStringToToken, replaceTokenT

export function getInspectorStateValueType(value, raw = true) {
const type = typeof value
if (value == null || value === UNDEFINED || value === 'undefined') {
if (value == null || value === UNDEFINED) {
return 'null'
}
else if (
Expand Down