Skip to content

Commit b98cc35

Browse files
authored
Auto merge of #36637 - GuillaumeGomez:fix_run_button, r=bluss
Fixes run button appearing when it shouldn't Fixes #36621. r? @steveklabnik
2 parents 19ac579 + 8983d1e commit b98cc35

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/librustdoc/html/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ r##"<!DOCTYPE html>
176176
krate = layout.krate,
177177
play_url = layout.playground_url,
178178
play_js = if layout.playground_url.is_empty() {
179-
"".to_string()
179+
format!(r#"<script src="{}extra.js"></script>"#, page.root_path)
180180
} else {
181181
format!(r#"<script src="{}playpen.js"></script>"#, page.root_path)
182-
},
182+
}
183183
)
184184
}
185185

src/librustdoc/html/static/extra.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2014-2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
/*jslint browser: true, es5: true */
12+
/*globals $: true, rootPath: true */
13+
14+
document.addEventListener('DOMContentLoaded', function() {
15+
'use strict';
16+
17+
if (!window.playgroundUrl) {
18+
var runButtons = document.querySelectorAll(".test-arrow");
19+
20+
for (var i = 0; i < runButtons.length; i++) {
21+
runButtons[i].classList.remove("test-arrow");
22+
}
23+
return;
24+
}
25+
});

src/librustdoc/html/static/playpen.js

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ document.addEventListener('DOMContentLoaded', function() {
1515
'use strict';
1616

1717
if (!window.playgroundUrl) {
18+
var runButtons = document.querySelectorAll(".test-arrow");
19+
20+
for (var i = 0; i < runButtons.length; i++) {
21+
runButtons[i].classList.remove("test-arrow");
22+
}
1823
return;
1924
}
2025

0 commit comments

Comments
 (0)