This repository was archived by the owner on Jun 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Sources/swift-doc/Subcommands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,10 +147,15 @@ func fetchRemoteJS() throws -> Data {
147147 let jsURL = Bundle . module. url ( forResource: " all " , withExtension: " js " ) !
148148 return try Data ( contentsOf: jsURL)
149149 #else
150- return Data ( """
151- window.addEventListener( " load " , ()=>{
150+ // When using Swift Package Manager versions that don't support bundled resources, just hide the theme select drop-down.
151+ let fallbackJS = """
152+ var hideThemeSelect = function() {
152153 document.querySelector( " .theme-select-container " ).hidden = true;
153- })
154- """ . utf8)
154+ }
155+ // hiding the element in `requestAnimationFrame` causes the function to be called after the element exists,
156+ // but fast enough that the element does not flash on the screen.
157+ window.requestAnimationFrame(hideThemeSelect)
158+ """
159+ return Data ( fallbackJS. utf8)
155160 #endif
156161}
You can’t perform that action at this time.
0 commit comments