diff --git a/js/content.js b/js/content.js index 0447457..f4c3bfc 100644 --- a/js/content.js +++ b/js/content.js @@ -167,6 +167,20 @@ }); } + /** + * Append the given HTML string at the end of the given child target node. + */ + parseHtmlAndAppendChild(targetNode, html) { + new DOMParser() + .parseFromString(html, 'text/html') + .querySelector('body') + .childNodes + .forEach(function(node) { + targetNode.appendChild(node); + } + ) + } + /** * Actually updates the UI by altering the DOM by adding our stuff. */ @@ -174,20 +188,21 @@ let self = this; mergeRequestsDetails.forEach(function(mergeRequest) { - let branchesInfoNode = document.createElement('div'); - - branchesInfoNode.classList.add('issuable-info'); - branchesInfoNode.innerHTML = '' + - '' + mergeRequest.source_branch + '' + - '' + - ' ' + - '' + - '' + mergeRequest.target_branch + '' + - ''; - - document - .querySelector('.mr-list .merge-request[data-iid="' + mergeRequest.iid + '"] .issuable-main-info') - .appendChild(branchesInfoNode); + let infoDiv = document + .querySelector('.mr-list .merge-request[data-iid="' + mergeRequest.iid + '"] .issuable-main-info'); + + let html = '