Skip to content

Commit 682e0df

Browse files
committed
fix: Configure AJAX after the library loads
If we configure AJAX before loading the library, the configuration is overridden.
1 parent 8e5d6d7 commit 682e0df

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/utils/remote-editor.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function initializeRemoteEditor() {
3232
.then( importL10n )
3333
.then( configureLocale ) // Configure locale before loading modules with strings
3434
.then( loadApiFetch )
35-
.then( configureNetworkingUtils ) // Configure AJAX and api-fetch before loading remaining modules
35+
.then( configureApiFetch ) // Configure api-fetch before loading remaining modules
3636
.then( loadRemainingAssets )
3737
.then( initializeEditor )
3838
.catch( handleError );
@@ -61,19 +61,21 @@ function loadRemainingAssets() {
6161
} );
6262
}
6363

64-
function configureNetworkingUtils( assetsResult ) {
65-
configureAjax();
66-
67-
return import( './api-fetch' ).then( ( { configureApiFetch } ) => {
68-
configureApiFetch();
69-
return assetsResult;
70-
} );
64+
function configureApiFetch( assetsResult ) {
65+
return import( './api-fetch' ).then(
66+
( { configureApiFetch: _configureApiFetch } ) => {
67+
_configureApiFetch();
68+
return assetsResult;
69+
}
70+
);
7171
}
7272

7373
function initializeEditor( assetsResult ) {
7474
const { allowedBlockTypes } = assetsResult;
7575
return import( './editor' ).then(
7676
( { initializeEditor: _initializeEditor } ) => {
77+
configureAjax();
78+
7779
_initializeEditor( { allowedBlockTypes } );
7880
}
7981
);

0 commit comments

Comments
 (0)