Skip to content

Commit 0ab8cc1

Browse files
authored
Rollup merge of #123784 - GuillaumeGomez:replace-document-write, r=notriddle
Replace `document.write` with `document.head.insertAdjacent` From [this comment](https://github.com/rust-lang/rust/pull/123706/files#r1559864981), using `document.write` is strongly discouraged (explained on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/write)). I think in this case it was mostly ok but better be on the safe side. r? `@notriddle`
2 parents da75aaf + 510bfc2 commit 0ab8cc1

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/librustdoc/html/templates/page.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
<meta name="description" content="{{page.description}}"> {# #}
88
<title>{{page.title}}</title> {# #}
99
<script>if(window.location.protocol!=="file:") {# Hack to skip preloading fonts locally - see #98769 #}
10-
for(f of "{{files.source_serif_4_regular}},{{files.fira_sans_regular}},{{files.fira_sans_medium}},{{files.source_code_pro_regular}},{{files.source_code_pro_semibold}}".split(",")) {# #}
11-
document.write(`<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}${f}">`) {# #}
10+
document.head.insertAdjacentHTML("beforeend","{{files.source_serif_4_regular}},{{files.fira_sans_regular}},{{files.fira_sans_medium}},{{files.source_code_pro_regular}},{{files.source_code_pro_semibold}}".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}${f}">`).join("")) {# #}
1211
</script> {# #}
1312
<link rel="stylesheet" {#+ #}
1413
href="{{static_root_path|safe}}{{files.normalize_css}}"> {# #}

0 commit comments

Comments
 (0)