Skip to content

Commit b3d2505

Browse files
committed
[test] 100% coverage
1 parent 9398ba6 commit b3d2505

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/ui-react/context.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import type {
3434
useSynchronizer as useSynchronizerDecl,
3535
useSynchronizerIds as useSynchronizerIdsDecl,
3636
} from '../@types/ui-react/index.d.ts';
37-
import {IdObj, objEnsure, objGet, objIds} from '../common/obj.ts';
37+
import {IdObj, objGet, objIds} from '../common/obj.ts';
3838
import {GLOBAL, isString, isUndefined} from '../common/other.ts';
3939
import {createContext, useContext, useEffect} from '../common/react.ts';
4040
import {TINYBASE} from '../common/strings.ts';
@@ -99,11 +99,14 @@ export type ContextValue = [
9999
delExtraThingById?: (offset: Offsets, id: string) => void,
100100
];
101101

102-
export const Context: React.Context<ContextValue> = objEnsure(
103-
GLOBAL,
104-
TINYBASE + '_uirc',
105-
() => createContext<ContextValue>([]),
106-
);
102+
const TINYBASE_CONTEXT = TINYBASE + '_uirc';
103+
104+
export const Context: React.Context<ContextValue> = (GLOBAL as any)[
105+
TINYBASE_CONTEXT
106+
]
107+
? /*! istanbul ignore next */
108+
(GLOBAL as any)[TINYBASE_CONTEXT]
109+
: ((GLOBAL as any)[TINYBASE_CONTEXT] = createContext<ContextValue>([]));
107110

108111
const useThing = <UsedThing extends Thing>(
109112
id: Id | undefined,

0 commit comments

Comments
 (0)