Skip to content

Commit

Permalink
Support default namespaces in getConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz committed Feb 9, 2024
1 parent eb0ea96 commit 34289a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/interactivity-router/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const { state, actions } = store( 'core/router', {
* @return {Promise} Promise that resolves once the navigation is completed or aborted.
*/
*navigate( href, options = {} ) {
const { clientNavigationDisabled } = getConfig( 'core/router' );
const { clientNavigationDisabled } = getConfig();
if ( clientNavigationDisabled ) {
yield forcePageReload( href );
}
Expand Down Expand Up @@ -225,7 +225,7 @@ export const { state, actions } = store( 'core/router', {
* fetching the requested URL.
*/
prefetch( url, options = {} ) {
const { clientNavigationDisabled } = getConfig( 'core/router' );
const { clientNavigationDisabled } = getConfig();
if ( clientNavigationDisabled ) return;

const pagePath = getPagePath( url );
Expand Down
2 changes: 1 addition & 1 deletion packages/interactivity/src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const namespaceStack: string[] = [];
* @return The context content.
*/
export const getContext = < T extends object >( namespace?: string ): T =>
getScope()?.context[ namespace || namespaceStack.slice( -1 )[ 0 ] ];
getScope()?.context[ namespace || getNamespace() ];

/**
* Retrieves a representation of the element where a function from the store
Expand Down
3 changes: 2 additions & 1 deletion packages/interactivity/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getScope,
setScope,
resetScope,
getNamespace,
setNamespace,
resetNamespace,
} from './hooks';
Expand Down Expand Up @@ -171,7 +172,7 @@ const handlers = {
* @return Defined config for the given namespace.
*/
export const getConfig = ( namespace: string ) =>
storeConfigs.get( namespace ) || {};
storeConfigs.get( namespace || getNamespace() ) || {};

interface StoreOptions {
/**
Expand Down

0 comments on commit 34289a9

Please sign in to comment.