Skip to content

api.js options and response headers, storage.js survives blocked storage

Choose a tag to compare

@github-actions github-actions released this 23 Nov 11:57
· 42 commits to main since this release

Based on feedback from using api.js and storage.js on a static landing page.

  • api.js - getJSON/postJSON/putJSON/deleteJSON send Content-Type: application/json only when there is a body, so a plain getJSON no longer triggers a CORS preflight and works against static hosts. The argument after responseFunction may be an options object { headers, timeout, cache } (the tokenkey, tokenvalue pair still works). Results also carry headers (the response Headers), error ("timeout", "offline" or "network" when status is 0) and cached. cache: { key, ttl } on getJSON keeps successful results in localStorage for ttl seconds, then revalidates with If-None-Match; a 304 returns the stored data with its stored status (200) and cached: true. Failures in every api.js function are logged with console.warn instead of console.log.
  • storage.js - blocked or full storage (private mode, strict privacy settings) no longer throws: getters return null, setters return false (true when saved), with one console warning.
  • mapmodel.js - the model's origin now lands exactly on its map point; the canvas offset ignored perspective and placed the base up to 5 px too high.
  • mapoffline.js - the HTTP Range fallback warning names the URL when it has no host (blob:).
  • tests/ - 55 tests: request headers, timeout, cache with ETag, and blocked localStorage.