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

Commit 88bb1e9

Browse files
committed
Fix UNSAFE_VAR_ASSIGNMENT in web-ext lint
1 parent 35d5306 commit 88bb1e9

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

js/content.js

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,42 @@
167167
});
168168
}
169169

170+
/**
171+
* Append the given HTML string at the end of the given child target node.
172+
*/
173+
parseHtmlAndAppendChild(targetNode, html) {
174+
new DOMParser()
175+
.parseFromString(html, 'text/html')
176+
.querySelector('body')
177+
.childNodes
178+
.forEach(function(node) {
179+
targetNode.appendChild(node);
180+
}
181+
)
182+
}
183+
170184
/**
171185
* Actually updates the UI by altering the DOM by adding our stuff.
172186
*/
173187
updateMergeRequestsNodes(mergeRequestsDetails) {
174188
let self = this;
175189

176190
mergeRequestsDetails.forEach(function(mergeRequest) {
177-
let branchesInfoNode = document.createElement('div');
178-
179-
branchesInfoNode.classList.add('issuable-info');
180-
branchesInfoNode.innerHTML = '<span class="project-ref-path has-tooltip" title="Source branch">' +
181-
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.source_branch + '">' + mergeRequest.source_branch + '</a>' +
182-
'</span>' +
183-
' <i class="fa fa-long-arrow-right" aria-hidden="true"></i> ' +
184-
'<span class="project-ref-path has-tooltip" title="Target branch">' +
185-
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.target_branch + '">' + mergeRequest.target_branch + '</a>' +
186-
'</span>';
187-
188-
document
189-
.querySelector('.mr-list .merge-request[data-iid="' + mergeRequest.iid + '"] .issuable-main-info')
190-
.appendChild(branchesInfoNode);
191+
let infoDiv = document
192+
.querySelector('.mr-list .merge-request[data-iid="' + mergeRequest.iid + '"] .issuable-main-info');
193+
194+
let html = '<div class="issuable-info"><span class="project-ref-path has-tooltip" title="Source branch">' +
195+
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.source_branch + '">' + mergeRequest.source_branch + '</a>' +
196+
'</span>' +
197+
' <i class="fa fa-long-arrow-right" aria-hidden="true"></i> ' +
198+
'<span class="project-ref-path has-tooltip" title="Target branch">' +
199+
'<a class="ref-name" href="' + self.baseProjectUrl + '/-/commits/' + mergeRequest.target_branch + '">' + mergeRequest.target_branch + '</a>' +
200+
'</span></div>';
201+
202+
self.parseHtmlAndAppendChild(
203+
infoDiv,
204+
html
205+
);
191206
});
192207
}
193208
}

0 commit comments

Comments
 (0)