Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit df4fd89

Browse files
committed
Make router turbo-compatible.
1 parent 282f259 commit df4fd89

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/app/router.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,20 @@ export default router;
124124

125125
// Handle editors inside pjax containers.
126126
{
127-
document.addEventListener( 'pjax:start', ( { target } ) => {
127+
document.addEventListener( 'turbo:before-visit', ( { target } ) => {
128+
/* istanbul ignore next */
129+
if ( process.env.NODE_ENV !== 'production' ) {
130+
console.log( 'navigation started -> destroying editors', target );
131+
}
132+
128133
Editor.destroyEditors( target );
129134
}, { passive: true } );
130135

131-
document.addEventListener( 'pjax:end', () => {
136+
document.addEventListener( 'turbo:render', () => {
132137
setTimeout( () => {
133138
/* istanbul ignore next */
134139
if ( process.env.NODE_ENV !== 'production' ) {
135-
console.log( `pjax ended -> running the router on "${ window.location.pathname }"` );
140+
console.log( `navigation ended -> running the router on "${ window.location.pathname }"` );
136141
}
137142

138143
router.run();

0 commit comments

Comments
 (0)