mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Ensure _.toPath works with symbols.
This commit is contained in:
@@ -14526,7 +14526,10 @@
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function toPath(value) {
|
function toPath(value) {
|
||||||
return isArray(value) ? arrayMap(value, baseCastKey) : stringToPath(value);
|
if (isArray(value)) {
|
||||||
|
return arrayMap(value, baseCastKey);
|
||||||
|
}
|
||||||
|
return isSymbol(value) ? [value] : stringToPath(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
15
test/test.js
15
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) {
|
QUnit.test('should handle complex paths', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user