about summary refs log tree commit diff
path: root/src/test/rustdoc-gui/sidebar-source-code.goml
diff options
context:
space:
mode:
authorJacob Hoffman-Andrews <github@hoffman-andrews.com>2022-06-20 12:41:11 -0700
committerJacob Hoffman-Andrews <github@hoffman-andrews.com>2022-06-20 15:08:02 -0700
commitb37a05bd01a4f1fdcdfda77df4a9008d04236528 (patch)
treec721c0c224e78af8a1526ff9d26c10878781888c /src/test/rustdoc-gui/sidebar-source-code.goml
parentbb8c2f41174caceec00c28bc6c5c20ae9f9a175c (diff)
downloadrust-b37a05bd01a4f1fdcdfda77df4a9008d04236528.tar.gz
rust-b37a05bd01a4f1fdcdfda77df4a9008d04236528.zip
rustdoc: optimize loading of source sidebar
The source sidebar has a setting to remember whether it should be open or
closed. Previously, this setting was handled in source-script.js, which
is loaded with `defer`, meaning it is often run after the document is rendered.
Since CSS renders the source sidebar as closed by default, changing this
after the initial render results in a relayout.

Instead, handle the setting in storage.js, which is the first script to load
and is the only script that blocks render. This avoids a relayout and means
navigating between files with the sidebar open is faster.
Diffstat (limited to 'src/test/rustdoc-gui/sidebar-source-code.goml')
-rw-r--r--src/test/rustdoc-gui/sidebar-source-code.goml10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/rustdoc-gui/sidebar-source-code.goml b/src/test/rustdoc-gui/sidebar-source-code.goml
index 8b4a8bd40dd..724520bc399 100644
--- a/src/test/rustdoc-gui/sidebar-source-code.goml
+++ b/src/test/rustdoc-gui/sidebar-source-code.goml
@@ -8,12 +8,12 @@ assert-css: ("nav.sidebar", {"width": "50px"})
 // We now click on the button to expand the sidebar.
 click: (10, 10)
 // We wait for the sidebar to be expanded.
-wait-for-css: ("nav.sidebar.expanded", {"width": "300px"})
-assert-css: ("nav.sidebar.expanded a", {"font-size": "14px"})
+wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"})
+assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
 // We collapse the sidebar.
 click: (10, 10)
 // We ensure that the class has been removed.
-wait-for: "nav.sidebar:not(.expanded)"
+wait-for: "html:not(.expanded)"
 assert: "nav.sidebar"
 
 // We now switch to mobile mode.
@@ -22,11 +22,11 @@ size: (600, 600)
 assert-css: ("nav.sidebar", {"width": "1px"})
 // We expand the sidebar.
 click: "#sidebar-toggle"
-assert-css: ("nav.sidebar.expanded", {"width": "600px"})
+assert-css: (".source-sidebar-expanded nav.sidebar", {"width": "600px"})
 // We collapse the sidebar.
 click: (10, 10)
 // We ensure that the class has been removed.
-assert-false: "nav.sidebar.expanded"
+assert-false: ".source-sidebar-expanded"
 assert: "nav.sidebar"
 
 // Check that the topbar is not visible