Skip to content

Commit e178030

Browse files
committed
Use createElement and innerHTML instead of DOMParser
@GuillaumeGomez was concerned about browser compatibility.
1 parent 5d4a712 commit e178030

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/librustdoc/html/static/main.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,11 +2040,9 @@ function defocusSearchBar() {
20402040
* @return {[string]} [The resulting plaintext]
20412041
*/
20422042
function convertHTMLToPlaintext(html) {
2043-
var dom = new DOMParser().parseFromString(
2044-
html.replace('<code>', '`').replace('</code>', '`'),
2045-
'text/html',
2046-
);
2047-
return dom.body.innerText;
2043+
var x = document.createElement("div");
2044+
x.innerHTML = html.replace('<code>', '`').replace('</code>', '`');
2045+
return x.innerText;
20482046
}
20492047

20502048

0 commit comments

Comments
 (0)