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

Commit ac2a63a

Browse files
authored
Merge pull request #348 from ckeditor/t/337
Fix for partial loading or not loading at all of the GitHub Writer
2 parents a404c50 + df4fd89 commit ac2a63a

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
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();

tests/unit/router.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ describe( 'Router', () => {
5656
} );
5757
} );
5858

59-
describe( 'pjax', () => {
60-
it( 'should destroy editors before pjax', () => {
59+
describe( 'turbo', () => {
60+
it( 'should destroy editors before turbo navigation', () => {
6161
const stub = sinon.stub( Editor, 'destroyEditors' );
6262
expect( stub.called, 'no call before' ).to.be.false;
6363

64-
document.body.dispatchEvent( new CustomEvent( 'pjax:start', { bubbles: true } ) );
64+
document.body.dispatchEvent( new CustomEvent( 'turbo:before-visit', { bubbles: true } ) );
6565

6666
expect( stub.calledOnce, 'one call after' ).to.be.true;
6767
expect( stub.firstCall.calledWith( document.body ) ).to.be.true;
6868
} );
6969

70-
it( 'should re-scan after pjax', done => {
70+
it( 'should re-scan after turbo rendering', done => {
7171
const stub = sinon.stub( router, 'run' );
7272
expect( stub.called, 'no call before' ).to.be.false;
7373

74-
document.body.dispatchEvent( new CustomEvent( 'pjax:end', { bubbles: true } ) );
74+
document.body.dispatchEvent( new CustomEvent( 'turbo:render', { bubbles: true } ) );
7575

7676
setTimeout( () => {
7777
expect( stub.calledOnce, 'one call after' ).to.be.true;

0 commit comments

Comments
 (0)