about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2020-11-17 12:24:16 -0800
committerCamelid <camelidcamel@gmail.com>2020-12-03 14:11:37 -0800
commite178030ea4d1b3a1e38cc53141188d2249d33cf5 (patch)
tree79f8cf3f8b75b0adc834d53f1f84b1ef754fdce3 /src/librustdoc/html
parent5d4a7128d9929723769a7c674f49e9fe3fc0ff13 (diff)
downloadrust-e178030ea4d1b3a1e38cc53141188d2249d33cf5.tar.gz
rust-e178030ea4d1b3a1e38cc53141188d2249d33cf5.zip
Use `createElement` and `innerHTML` instead of `DOMParser`
@GuillaumeGomez was concerned about browser compatibility.
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/static/main.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 712ea044e48..0884351a9fd 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -2040,11 +2040,9 @@ function defocusSearchBar() {
      * @return {[string]}      [The resulting plaintext]
      */
     function convertHTMLToPlaintext(html) {
-        var dom = new DOMParser().parseFromString(
-            html.replace('<code>', '`').replace('</code>', '`'),
-            'text/html',
-        );
-        return dom.body.innerText;
+        var x = document.createElement("div");
+        x.innerHTML = html.replace('<code>', '`').replace('</code>', '`');
+        return x.innerText;
     }