mirror of
https://github.com/zhukunpenglinyutong/jetbrains-cc-gui.git
synced 2026-09-01 15:48:11 +08:00
0d63d4453c
- Add isInputDirtyRef to prevent useControlledValueSync from overwriting DOM with stale debounced value during fast typing - Add drag-resize handle to PermissionDialog (v3) and PlanApprovalDialog so users can expand them to see more content - Add localStorage polyfill in vitest-setup.ts for Node.js 25 compatibility - Fix useInputHistory test mocks for localStorage.setItem Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
// Node.js 22+ exposes a built-in localStorage on globalThis that lacks
|
|
// full Storage API methods (e.g. clear) when --localstorage-file is not set.
|
|
// This conflicts with jsdom's own localStorage implementation.
|
|
// Replace it with a spec-compliant in-memory Storage polyfill.
|
|
function createStorage(): Storage {
|
|
let store: Record<string, string> = {};
|
|
return {
|
|
getItem(key: string) {
|
|
return Object.prototype.hasOwnProperty.call(store, key) ? store[key] : null;
|
|
},
|
|
setItem(key: string, value: string) {
|
|
store[key] = String(value);
|
|
},
|
|
removeItem(key: string) {
|
|
delete store[key];
|
|
},
|
|
clear() {
|
|
store = {};
|
|
},
|
|
key(index: number) {
|
|
return Object.keys(store)[index] ?? null;
|
|
},
|
|
get length() {
|
|
return Object.keys(store).length;
|
|
},
|
|
};
|
|
}
|
|
|
|
if (!globalThis.localStorage || typeof globalThis.localStorage.clear !== 'function') {
|
|
Object.defineProperty(globalThis, 'localStorage', {
|
|
value: createStorage(),
|
|
writable: true,
|
|
configurable: true,
|
|
});
|
|
}
|