2021-07-21 17:10:10 -04:00
|
|
|
// TODO: With the combined_menu feature flag removed, there's likely a better
|
|
|
|
// way to slice up the async import (i.e., include trigger in main bundle, but
|
|
|
|
// async import subviews. Don't do this at the cost of UX).
|
|
|
|
// See https://gitlab.com/gitlab-org/gitlab/-/issues/336042
|
2021-06-08 20:10:20 -04:00
|
|
|
const importModule = () => import(/* webpackChunkName: 'top_nav' */ './mount');
|
|
|
|
|
|
|
|
const tryMountTopNav = async () => {
|
2021-05-17 14:10:42 -04:00
|
|
|
const el = document.getElementById('js-top-nav');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-08 20:10:20 -04:00
|
|
|
const { mountTopNav } = await importModule();
|
2021-05-17 14:10:42 -04:00
|
|
|
|
|
|
|
mountTopNav(el);
|
|
|
|
};
|
2021-06-08 20:10:20 -04:00
|
|
|
|
|
|
|
const tryMountTopNavResponsive = async () => {
|
|
|
|
const el = document.getElementById('js-top-nav-responsive');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { mountTopNavResponsive } = await importModule();
|
|
|
|
|
|
|
|
mountTopNavResponsive(el);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const initTopNav = async () => Promise.all([tryMountTopNav(), tryMountTopNavResponsive()]);
|