Ensure _.toPath works with symbols.

This commit is contained in:
John-David Dalton
2016-03-04 08:09:39 -08:00
parent 760a00b82f
commit e02ce1ea8b
2 changed files with 19 additions and 1 deletions

View File

@@ -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);
}
/**

View File

@@ -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);