diff --git a/lodash.js b/lodash.js index 5f00dc612..10cee4c3f 100644 --- a/lodash.js +++ b/lodash.js @@ -14526,7 +14526,10 @@ * // => false */ function toPath(value) { - return isArray(value) ? arrayMap(value, baseCastKey) : stringToPath(value); + if (isArray(value)) { + return arrayMap(value, baseCastKey); + } + return isSymbol(value) ? [value] : stringToPath(value); } /** diff --git a/test/test.js b/test/test.js index 7738305f6..982f412ed 100644 --- a/test/test.js +++ b/test/test.js @@ -22111,6 +22111,21 @@ }); }); + QUnit.test('should not coerce symbols to strings', function(assert) { + assert.expect(4); + + if (Symbol) { + var object = Object(symbol); + lodashStable.each([symbol, object, [symbol], [object]], function(value) { + var actual = _.toPath(value); + assert.ok(lodashStable.isSymbol(actual[0])); + }); + } + else { + skipAssert(assert, 4); + } + }); + QUnit.test('should handle complex paths', function(assert) { assert.expect(1);