File tree Expand file tree Collapse file tree 3 files changed +32
-11
lines changed Expand file tree Collapse file tree 3 files changed +32
-11
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ const loadCopyButton = () => {
21
21
codeEl . querySelectorAll ( '.go, .gp, .gt' ) . forEach ( el => el . hidden = true )
22
22
codeEl . querySelectorAll ( '.gt' ) . forEach ( el => {
23
23
while ( ( el = el . nextSibling ) && el . nodeType !== Node . DOCUMENT_NODE ) {
24
- if ( el . nodeType === Node . ELEMENT_NODE && el . matches ( ".gp, .go" ) ) break
24
+ if ( el . nodeType === Node . ELEMENT_NODE && el . matches ( ".gp, .go" ) ) {
25
+ break
26
+ }
25
27
if ( el . nodeType === Node . TEXT_NODE && el . textContent . trim ( ) ) {
26
28
const wrapper = document . createElement ( 'span' )
27
29
el . after ( wrapper )
@@ -55,9 +57,14 @@ const loadCopyButton = () => {
55
57
// if we find a console prompt (.gp), prepend the (deeply cloned) button
56
58
const clonedButton = button . cloneNode ( true )
57
59
clonedButton . onclick = buttonClick // onclick isn't cloned :(
58
- if ( el . querySelector ( ".gp" ) !== null ) el . prepend ( clonedButton )
60
+ if ( el . querySelector ( ".gp" ) !== null ) {
61
+ el . prepend ( clonedButton )
62
+ }
59
63
} )
60
64
}
61
65
62
- if ( document . readyState !== "loading" ) loadCopyButton ( )
63
- else document . addEventListener ( "DOMContentLoaded" , loadCopyButton )
66
+ if ( document . readyState !== "loading" ) {
67
+ loadCopyButton ( )
68
+ } else {
69
+ document . addEventListener ( "DOMContentLoaded" , loadCopyButton )
70
+ }
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ document.addEventListener('DOMContentLoaded', function () {
31
31
// Close menu when link on the sideMenu is clicked
32
32
sideMenu . addEventListener ( 'click' , function ( event ) {
33
33
let target = event . target
34
- if ( target . tagName . toLowerCase ( ) !== 'a' ) return
34
+ if ( target . tagName . toLowerCase ( ) !== 'a' ) {
35
+ return
36
+ }
35
37
closeMenu ( )
36
38
} )
37
39
// Add accessibility data when sideMenu is opened/closed
Original file line number Diff line number Diff line change @@ -34,7 +34,9 @@ const initialiseSidebar = () => {
34
34
const sidebarArrow = sidebarButton . querySelector ( 'span' )
35
35
36
36
// for some reason, the document has no sidebar do not run into errors
37
- if ( typeof sidebar === "undefined" ) return
37
+ if ( typeof sidebar === "undefined" ) {
38
+ return
39
+ }
38
40
39
41
const flipArrow = element => element . innerText = ( element . innerText === "»" ) ? "«" : "»"
40
42
@@ -60,11 +62,21 @@ const initialiseSidebar = () => {
60
62
( sidebarWrapper . style . display === "none" ) ? expand_sidebar ( ) : collapse_sidebar ( )
61
63
} )
62
64
63
- if ( ! window . localStorage . getItem ( "sidebar" ) ) return
65
+ if ( ! window . localStorage . getItem ( "sidebar" ) ) {
66
+ return
67
+ }
64
68
const value = window . localStorage . getItem ( "sidebar" )
65
- if ( value === "collapsed" ) collapse_sidebar ( )
66
- else if ( value === "expanded" ) expand_sidebar ( )
69
+ if ( value === "collapsed" ) {
70
+ collapse_sidebar ( )
71
+ }
72
+ else if ( value === "expanded" ) {
73
+ expand_sidebar ( )
74
+ }
67
75
}
68
76
69
- if ( document . readyState !== "loading" ) initialiseSidebar ( )
70
- else document . addEventListener ( "DOMContentLoaded" , initialiseSidebar )
77
+ if ( document . readyState !== "loading" ) {
78
+ initialiseSidebar ( )
79
+ }
80
+ else {
81
+ document . addEventListener ( "DOMContentLoaded" , initialiseSidebar )
82
+ }
You can’t perform that action at this time.
0 commit comments