-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetDomElementsToClientState.ts
More file actions
35 lines (26 loc) · 1.1 KB
/
setDomElementsToClientState.ts
File metadata and controls
35 lines (26 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type {ReportClientState} from '../../../types/internal';
declare const reportClientState: ReportClientState;
type Options = Readonly<{afterDomContentLoad?: boolean}> | undefined;
/**
* Set dynamic DOM elements to `reportClientState`.
* This client function should not use scope variables (except global functions).
* @internal
*/
export const setDomElementsToClientState = ({afterDomContentLoad = false}: Options = {}): void => {
let {e2edRightColumnContainer} = reportClientState;
if (e2edRightColumnContainer) {
return;
}
e2edRightColumnContainer = document.getElementById('e2edRightColumnContainer') ?? undefined;
if (e2edRightColumnContainer) {
Object.assign<ReportClientState, Partial<ReportClientState>>(reportClientState, {
e2edRightColumnContainer,
});
return;
}
const messageTail = afterDomContentLoad
? ' after DOMContentLoaded'
: '. Probably page not yet completely loaded. Please try click again later';
// eslint-disable-next-line no-console
console.error(`Cannot find right column container (id="e2edRightColumnContainer")${messageTail}`);
};