From 8e6f3e48d040842de4e0b45cd4b387eed2a36083 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 4 Mar 2016 07:33:16 -0800 Subject: [PATCH] Ensure `getOwnPropertySymbols` is passed an object to avoid errors in V8. --- lodash.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index 8807dbdba..ccf2d4b9e 100644 --- a/lodash.js +++ b/lodash.js @@ -5063,9 +5063,18 @@ * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ - var getSymbols = getOwnPropertySymbols || function() { - return []; - }; + function getSymbols(object) { + // Coerce `object` to an object to avoid non-object errors in V8. + // See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details. + return getOwnPropertySymbols(Object(object)); + } + + // Fallback for IE < 11. + if (!getOwnPropertySymbols) { + getSymbols = function() { + return []; + }; + } /** * Creates an array of the own and inherited enumerable symbol properties