All files / publisher/market storageCommands.ts

100% Statements 12/12
100% Branches 6/6
100% Functions 1/1
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29              10x 10x 9x 9x   3x 3x   3x 3x 3x   2x 2x       10x        
function storageCommands(
  e: StorageEvent,
  formEl: HTMLFormElement,
  snap_name: string,
  ignoreChangesOnUnload: Function,
  context = window,
) {
  const key = `${snap_name}-command`;
  if (e.key === key) {
    context.localStorage.removeItem(key);
    switch (e.newValue) {
      case "edit":
        context.focus();
        break;
      case "revert":
        ignoreChangesOnUnload();
        context.location.reload();
        break;
      case "save":
        formEl.dispatchEvent(new Event("submit"));
        break;
    }
  }
 
  return;
}
 
export { storageCommands };