@@ -32,7 +32,11 @@ function hashLinkScroll() {
32
32
if ( observer === null ) {
33
33
observer = new MutationObserver ( getElAndScroll ) ;
34
34
}
35
- observer . observe ( document , { attributes : true , childList : true , subtree : true } ) ;
35
+ observer . observe ( document , {
36
+ attributes : true ,
37
+ childList : true ,
38
+ subtree : true ,
39
+ } ) ;
36
40
// if the element doesn't show up in 10 seconds, stop checking
37
41
asyncTimerId = window . setTimeout ( ( ) => {
38
42
reset ( ) ;
@@ -46,13 +50,23 @@ export function genericHashLink(props, As) {
46
50
reset ( ) ;
47
51
if ( props . onClick ) props . onClick ( e ) ;
48
52
if ( typeof props . to === 'string' ) {
49
- hashFragment = props . to . split ( '#' ) . slice ( 1 ) . join ( '#' ) ;
50
- } else if ( typeof props . to === 'object' && typeof props . to . hash === 'string' ) {
53
+ hashFragment = props . to
54
+ . split ( '#' )
55
+ . slice ( 1 )
56
+ . join ( '#' ) ;
57
+ } else if (
58
+ typeof props . to === 'object' &&
59
+ typeof props . to . hash === 'string'
60
+ ) {
51
61
hashFragment = props . to . hash . replace ( '#' , '' ) ;
52
62
}
53
63
if ( hashFragment !== '' ) hashLinkScroll ( ) ;
54
64
}
55
- return < As { ...props } onClick = { handleClick } > { props . children } </ As > ;
65
+ return (
66
+ < As { ...props } onClick = { handleClick } >
67
+ { props . children }
68
+ </ As >
69
+ ) ;
56
70
}
57
71
58
72
export function HashLink ( props ) {
@@ -66,10 +80,7 @@ export function NavHashLink(props) {
66
80
const propTypes = {
67
81
onClick : PropTypes . func ,
68
82
children : PropTypes . node ,
69
- to : PropTypes . oneOfType ( [
70
- PropTypes . string ,
71
- PropTypes . object ,
72
- ] ) ,
83
+ to : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . object ] ) ,
73
84
} ;
74
85
75
86
HashLink . propTypes = propTypes ;
0 commit comments