1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-03 02:44:57 +12:00

code review: avoid using innerHTML

This commit is contained in:
gorhill 2017-12-01 17:16:29 -05:00
parent fa95f964de
commit 03120f8dd9
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -504,13 +504,16 @@ var nodeListsAddedHandler = function(nodeLists) {
var renderNoscriptTags = function(response) {
if ( response !== true ) { return; }
var parent, span;
var parser = new DOMParser();
var doc, parent, span, meta;
for ( var noscript of noscripts ) {
parent = noscript.parentNode;
if ( parent === null ) { continue; }
span = document.createElement('span');
span.innerHTML = noscript.textContent;
doc = parser.parseFromString(
'<span>' + noscript.textContent + '</span>',
'text/html'
);
span = document.adoptNode(doc.querySelector('span'));
span.style.setProperty('display', 'inline', 'important');
parent.replaceChild(span, noscript);
}