Skip to content

Commit f46e84c

Browse files
author
Brian Lonsdorf
authored
Merge pull request #1969 from salesforce-ux/merge-winter-17-into-spring-17
Merge winter 17 into spring 17
2 parents b838ef9 + 3843666 commit f46e84c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

app_modules/util/lodash_id_overwrite.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,28 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1010
*/
1111
let idCounter = 0;
1212

13+
const PREFIXES = {};
14+
1315
// SHIM Lodash because it caches in node_modules and generates id's that are always incrementing
1416
import _ from 'lodash';
1517

16-
function uniqueId(prefix) {
17-
var id = ++idCounter;
18-
return prefix ? prefix + id : id;
19-
}
18+
const newCounter = prefix =>
19+
PREFIXES[prefix] = 0;
20+
21+
const incCounter = prefix =>
22+
PREFIXES[prefix] = PREFIXES[prefix] + 1;
23+
24+
const initCounterForPrefix = prefix =>
25+
PREFIXES[prefix] != null
26+
? PREFIXES[prefix]
27+
: newCounter(prefix);
28+
29+
const addToPrefix = prefix => {
30+
initCounterForPrefix(prefix);
31+
return prefix + incCounter(prefix);
32+
};
33+
34+
const uniqueId = prefix =>
35+
prefix ? addToPrefix(prefix) : idCounter++;
36+
2037
_.uniqueId = uniqueId;

0 commit comments

Comments
 (0)