Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Fix UNSAFE_VAR_ASSIGNMENT in web-ext lint
Browse files Browse the repository at this point in the history
  • Loading branch information
EpocDotFr committed Mar 21, 2020
1 parent 35d5306 commit 88bb1e9
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,42 @@
});
}

/**
* 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.
*/
updateMergeRequestsNodes(mergeRequestsDetails) {
let self = this;

mergeRequestsDetails.forEach(function(mergeRequest) {
let branchesInfoNode = document.createElement('div');

branchesInfoNode.classList.add('issuable-info');
branchesInfoNode.innerHTML = '<span class="project-ref-path has-tooltip" title="Source branch">' +
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.source_branch + '">' + mergeRequest.source_branch + '</a>' +
'</span>' +
' <i class="fa fa-long-arrow-right" aria-hidden="true"></i> ' +
'<span class="project-ref-path has-tooltip" title="Target branch">' +
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.target_branch + '">' + mergeRequest.target_branch + '</a>' +
'</span>';

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 = '<div class="issuable-info"><span class="project-ref-path has-tooltip" title="Source branch">' +
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.source_branch + '">' + mergeRequest.source_branch + '</a>' +
'</span>' +
' <i class="fa fa-long-arrow-right" aria-hidden="true"></i> ' +
'<span class="project-ref-path has-tooltip" title="Target branch">' +
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.target_branch + '">' + mergeRequest.target_branch + '</a>' +
'</span></div>';

self.parseHtmlAndAppendChild(
infoDiv,
html
);
});
}
}
Expand Down

0 comments on commit 88bb1e9

Please sign in to comment.