@@ -24,25 +24,18 @@ document.addEventListener('click', async function(e) {
24
24
return outlet . getAttribute ( 'data-route' ) === targetUrl . pathname ;
25
25
} ) [ 0 ] ;
26
26
27
- console . debug ( { currentUrl } ) ;
28
- console . debug ( { targetUrl } ) ;
29
-
30
27
// maintain the app shell if we are navigating between pages that are built from the same page template
31
28
// also, some routes may be SSR, so we may not always match on a static route
32
29
if ( routerOutlet && routerOutlet . getAttribute ( 'data-template' ) === window . __greenwood . currentTemplate ) {
33
30
const { hash, pathname } = targetUrl ;
34
- console . debug ( 'TARGET PATHNAME' , { pathname } ) ;
35
- console . debug ( 'TARGET HASH' , { hash } ) ;
36
31
37
32
if ( currentUrl . pathname !== pathname ) {
38
- console . debug ( '111 PUSH STATE TO NEW PATHNAME' ) ;
39
33
await routerOutlet . loadRoute ( ) ;
40
- // history.pushState({}, '', `${targetUrl.pathname}${targetUrl.hash}`);
34
+
41
35
history . pushState ( { } , '' , pathname ) ;
42
36
}
43
37
44
38
if ( hash !== '' ) {
45
- console . debug ( '222 HASH' ) ;
46
39
currentUrl . hash = hash ;
47
40
}
48
41
} else {
@@ -53,17 +46,14 @@ document.addEventListener('click', async function(e) {
53
46
}
54
47
} ) ;
55
48
56
- window . addEventListener ( 'popstate' , ( event ) => {
49
+ window . addEventListener ( 'popstate' , ( ) => {
57
50
try {
58
- console . debug ( 'popstate' , { event } ) ;
59
51
const targetRoute = window . location ;
60
52
const routerOutlet = Array . from ( document . getElementsByTagName ( 'greenwood-route' ) ) . filter ( outlet => {
61
53
return outlet . getAttribute ( 'data-route' ) === targetRoute . pathname ;
62
54
} ) [ 0 ] ;
63
55
64
56
if ( routerOutlet ) {
65
- console . debug ( 'popstate loadRoute' ) ;
66
- // TODO do we need to handle hash here too?
67
57
routerOutlet . loadRoute ( ) ;
68
58
}
69
59
} catch ( err ) {
@@ -78,7 +68,6 @@ class RouteComponent extends HTMLElement {
78
68
await fetch ( key )
79
69
. then ( res => res . text ( ) )
80
70
. then ( ( response ) => {
81
- console . debug ( 'HTML LOADED!!!' ) ;
82
71
document . getElementsByTagName ( 'router-outlet' ) [ 0 ] . innerHTML = response ;
83
72
} ) ;
84
73
}
0 commit comments