diff options
Diffstat (limited to 'app/assets/javascripts/issues/related_merge_requests/index.js')
-rw-r--r-- | app/assets/javascripts/issues/related_merge_requests/index.js | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/app/assets/javascripts/issues/related_merge_requests/index.js b/app/assets/javascripts/issues/related_merge_requests/index.js index ce33cf7df1d..5045f7e1a2a 100644 --- a/app/assets/javascripts/issues/related_merge_requests/index.js +++ b/app/assets/javascripts/issues/related_merge_requests/index.js @@ -2,23 +2,21 @@ import Vue from 'vue'; import RelatedMergeRequests from './components/related_merge_requests.vue'; import createStore from './store'; -export default function initRelatedMergeRequests() { - const relatedMergeRequestsElement = document.querySelector('#js-related-merge-requests'); +export function initRelatedMergeRequests() { + const el = document.querySelector('#js-related-merge-requests'); - if (relatedMergeRequestsElement) { - const { endpoint, projectPath, projectNamespace } = relatedMergeRequestsElement.dataset; - - // eslint-disable-next-line no-new - new Vue({ - el: relatedMergeRequestsElement, - components: { - RelatedMergeRequests, - }, - store: createStore(), - render: (createElement) => - createElement('related-merge-requests', { - props: { endpoint, projectNamespace, projectPath }, - }), - }); + if (!el) { + return undefined; } + + const { endpoint, projectPath, projectNamespace } = el.dataset; + + return new Vue({ + el, + store: createStore(), + render: (createElement) => + createElement(RelatedMergeRequests, { + props: { endpoint, projectNamespace, projectPath }, + }), + }); } |