Package
@stoplight/mosaic@1.53.5
Problem
The in-memory storage fallback used by Mosaic’s persisted theme store implements getItem and setItem, but not removeItem.
When Mosaic selects this fallback because browser storage is unavailable, clearing the persisted theme value can fail because the storage object does not satisfy the complete interface expected by the persisted store.
The fallback currently has the equivalent of:
const memoryStorage = {
getItem: name => memoryDb[name],
setItem: (name, value) => {
memoryDb[name] = value;
},
};
Expected behavior
The memory fallback should support removing a stored value:
const memoryStorage = {
getItem: name => memoryDb[name],
setItem: (name, value) => {
memoryDb[name] = value;
},
removeItem: name => {
delete memoryDb[name];
},
};
It may also be useful for the theme-storage selector to verify that the selected localStorage implementation provides removeItem, rather than checking only whether localStorage is defined.
Downstream context
This was encountered while rendering Stellar API documentation in environments that do not provide a complete browser storage implementation.
A downstream patch was prepared in stellar/stellar-docs#2416, but the project would prefer to resolve the defect upstream rather than maintain a package patch.
Package
@stoplight/mosaic@1.53.5Problem
The in-memory storage fallback used by Mosaic’s persisted theme store implements
getItemandsetItem, but notremoveItem.When Mosaic selects this fallback because browser storage is unavailable, clearing the persisted theme value can fail because the storage object does not satisfy the complete interface expected by the persisted store.
The fallback currently has the equivalent of:
Expected behavior
The memory fallback should support removing a stored value:
It may also be useful for the theme-storage selector to verify that the selected
localStorageimplementation providesremoveItem, rather than checking only whetherlocalStorageis defined.Downstream context
This was encountered while rendering Stellar API documentation in environments that do not provide a complete browser storage implementation.
A downstream patch was prepared in
stellar/stellar-docs#2416, but the project would prefer to resolve the defect upstream rather than maintain a package patch.