1 | import { getWindow } from './dom/getWindow';
|
2 | import { Stylesheet } from '@uifabric/merge-styles';
|
3 |
|
4 | var CURRENT_ID_PROPERTY = '__currentId__';
|
5 | var DEFAULT_ID_STRING = 'id__';
|
6 |
|
7 | var _global = getWindow() || {};
|
8 | if (_global[CURRENT_ID_PROPERTY] === undefined) {
|
9 | _global[CURRENT_ID_PROPERTY] = 0;
|
10 | }
|
11 | var _initializedStylesheetResets = false;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export function getId(prefix) {
|
18 | if (!_initializedStylesheetResets) {
|
19 |
|
20 | var stylesheet = Stylesheet.getInstance();
|
21 | if (stylesheet && stylesheet.onReset) {
|
22 | stylesheet.onReset(resetIds);
|
23 | }
|
24 | _initializedStylesheetResets = true;
|
25 | }
|
26 | var index = _global[CURRENT_ID_PROPERTY]++;
|
27 | return (prefix === undefined ? DEFAULT_ID_STRING : prefix) + index;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | export function resetIds(counter) {
|
35 | if (counter === void 0) { counter = 0; }
|
36 | _global[CURRENT_ID_PROPERTY] = counter;
|
37 | }
|
38 |
|
\ | No newline at end of file |