Commit e36f62ad authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'leipert-safeguard-initalizations' into 'master'

Safeguard initalizations

See merge request gitlab-org/gitlab!42133
parents 99ba0b38 746806b8
...@@ -111,18 +111,21 @@ function deferredInitialisation() { ...@@ -111,18 +111,21 @@ function deferredInitialisation() {
initPersistentUserCallouts(); initPersistentUserCallouts();
initDefaultTrackers(); initDefaultTrackers();
document.querySelector('#search').addEventListener( const search = document.querySelector('#search');
'focus', if (search) {
() => { search.addEventListener(
import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete') 'focus',
.then(({ default: initSearchAutocomplete }) => { () => {
const searchDropdown = initSearchAutocomplete(); import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete')
searchDropdown.onSearchInputFocus(); .then(({ default: initSearchAutocomplete }) => {
}) const searchDropdown = initSearchAutocomplete();
.catch(() => {}); searchDropdown.onSearchInputFocus();
}, })
{ once: true }, .catch(() => {});
); },
{ once: true },
);
}
addSelectOnFocusBehaviour('.js-select-on-focus'); addSelectOnFocusBehaviour('.js-select-on-focus');
......
...@@ -5,14 +5,15 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -5,14 +5,15 @@ import axios from '~/lib/utils/axios_utils';
import PerformanceBarService from './services/performance_bar_service'; import PerformanceBarService from './services/performance_bar_service';
import PerformanceBarStore from './stores/performance_bar_store'; import PerformanceBarStore from './stores/performance_bar_store';
const initPerformanceBar = ({ container }) => const initPerformanceBar = el => {
new Vue({ const performanceBarData = el.dataset;
el: container,
return new Vue({
el,
components: { components: {
PerformanceBarApp: () => import('./components/performance_bar_app.vue'), PerformanceBarApp: () => import('./components/performance_bar_app.vue'),
}, },
data() { data() {
const performanceBarData = document.querySelector(this.$options.el).dataset;
const store = new PerformanceBarStore(); const store = new PerformanceBarStore();
return { return {
...@@ -118,9 +119,13 @@ const initPerformanceBar = ({ container }) => ...@@ -118,9 +119,13 @@ const initPerformanceBar = ({ container }) =>
}); });
}, },
}); });
};
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
initPerformanceBar({ container: '#js-peek' }); const jsPeek = document.querySelector('#js-peek');
if (jsPeek) {
initPerformanceBar(jsPeek);
}
}); });
export default initPerformanceBar; export default initPerformanceBar;
...@@ -44,7 +44,7 @@ describe('performance bar wrapper', () => { ...@@ -44,7 +44,7 @@ describe('performance bar wrapper', () => {
{}, {},
); );
vm = performanceBar({ container: '#js-peek' }); vm = performanceBar(peekWrapper);
}); });
afterEach(() => { afterEach(() => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment