Skip to content

Commit 65b658a

Browse files
Xesenixjohnjbarton
authored andcommitted
fix(common): stringify error on 'Cannot convert a Symbol value to a string' (#2990)
Fixes #2856
1 parent c1526a1 commit 65b658a

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

common/stringify.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var stringify = function stringify (obj, depth) {
1414
}
1515

1616
switch (typeof obj) {
17+
case 'symbol':
18+
return obj.toString()
1719
case 'string':
1820
return "'" + obj + "'"
1921
case 'undefined':

test/client/stringify.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ var assert = require('assert')
44
var stringify = require('../../common/stringify')
55

66
describe('stringify', function () {
7+
it('should serialize symbols', function () {
8+
assert.deepEqual(stringify(Symbol.for('x')), 'Symbol(x)')
9+
})
10+
711
it('should serialize string', function () {
812
assert.deepEqual(stringify('aaa'), "'aaa'")
913
})

0 commit comments

Comments
 (0)