-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLANET-7175 Fix timeline block editor error (#2250)
Ref. https://jira.greenpeace.org/browse/PLANET-7175 The error was caused by conflicts between the underscore and lodash libraries.
- Loading branch information
1 parent
daaf80d
commit 5d71f31
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Determines if _ is lodash or not. | ||
export const isLodash = () => { | ||
let isItLodash = false; | ||
|
||
// If _ is defined and the function _.forEach exists then we know underscore OR lodash are in place | ||
// eslint-disable-next-line no-undef | ||
if ('undefined' !== typeof (_) && 'function' === typeof (_.forEach)) { | ||
// A small sample of some of the functions that exist in lodash but not underscore | ||
const funcs = ['get', 'set', 'at', 'cloneDeep']; | ||
|
||
// Simplest if assume exists to start | ||
isItLodash = true; | ||
|
||
funcs.forEach(func => { | ||
// If just one of the functions do not exist, then not lodash | ||
// eslint-disable-next-line no-undef | ||
isItLodash = ('function' !== typeof (_[func])) ? false : isItLodash; | ||
}); | ||
} | ||
|
||
if (isItLodash) { | ||
// We know that lodash is loaded in the _ variable | ||
return true; | ||
} | ||
// We know that lodash is NOT loaded | ||
return false; | ||
}; |