Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

version-switcher

Surface and switch between versions of a page over time: release versions or per-page history, with navigate, swap and diff actions, an archived-version banner and page-info mounting.

Overview

<version-switcher> renders a small trigger button showing the current version of a page; clicking opens a picker popover listing every available version. Two modes auto-detected from the data shape:

  • Releases — entries have distinct URLs (/v1/page, /v2/page). Classic docs version selector.
  • History — entries share one URL but differ by date / author. Per-page edit-history list.

Override with data-mode="releases" or data-mode="history" if the data is ambiguous.

Provenance integration

Meta-tag manifest fallback

If no inline data-versions and no data-src are provided, the component falls back to <meta name="vb:versions-manifest"> and fetches the URL listed there. The provenance build pipeline emits this tag from the page's versionsManifest frontmatter (per meta-tag-contract-v1).

Archived-version banner

Set data-banner to render a full-width warning banner above the trigger when the current version is archived AND a non-archived "latest" version exists. The banner is a labelled <aside> holding a role="status" line. The line is inserted empty and filled a moment later, so screen readers announce the notice. The Latest pointer is a link only when the latest entry has a safe url.

Mount inside <page-info>

Set data-page-info-target="ID" to render the version list as a section inside the named <page-info>'s expandable panel instead of a standalone trigger. The standalone trigger is hidden in this mode, so readers find versions in the page-info panel next to authorship and provenance. The section gets the same entry styling as the picker, and it is removed when the switcher leaves the page.

Switch actions

Pick the action via data-action. Each action operates on the current page's versioned region — the first [data-versioned] element, or <main> when the page has none. Set data-versioned-region to a CSS selector to choose another element.

ActionBehavior
navigate (default)Sets location.href to the picked entry's url. Cancellable via version-switcher:before-navigate. If the url is the page you are on, as with history entries that share one URL, nothing reloads; a version-switcher:error fires instead. Give each revision its own URL (for example /policy?rev=2026-04-01), or use swap or diff.
swapFetches the picked URL (same-origin only), extracts its versioned region, sanitizes it, and replaces the current versioned region in place. Updates <meta itemprop="version"> with the picked id. Uses document.startViewTransition for a crossfade when supported. Emits version-switcher:before-swap (cancellable) then version-switcher:swap.
diffFetches the picked URL (same-origin only), computes a line-level diff against the current versioned region, and mounts a <change-set> sibling containing the diff (use the change-set's tracking-view buttons to flip between final / original / both). data-diff-position="before|after" controls placement. Emits version-switcher:before-diff (cancellable) then version-switcher:diff.

When to use which primitive

Use thisWhen
<version-switcher>Switch between known versions of THIS page (releases or history snapshots).
<page-info>Show the current version + provenance + authors. Complementary — not the same. page-info answers "what version is this?"; version-switcher answers "what other versions exist?".
<time-index>Site-wide changelog timeline (releases of the whole project).
<change-set>Inline visual diff of authored markup (<ins>/<del>). The diff action renders into one.

Author surface

Inline the version list as JSON, either via the data-versions attribute or a <script type="application/json" data-versions> child.

Version entry shape

FieldTypeRequiredDescription
idstringyesStable identifier (semver, commit sha, "current", etc.).
labelstringnoDisplay label (defaults to id).
urlstringrecommendedURL to navigate to (or fetch, for swap / diff). An entry whose url is a javascript:, vbscript: or data: URL is dropped.
datestring (ISO-8601)noRenders as a localised relative time (Intl.RelativeTimeFormat, nearest [lang]) with the full date in the tooltip.
authorstringnoUseful in history mode.
summarystringnoOne-line description (release-note excerpt or commit message).
archivedbooleannoRenders the "archived" badge and mutes the entry.
draftbooleannoRenders the "draft" badge.
currentbooleannoMarks the current entry. If absent, derived from a matching <meta itemprop="version"> or the first entry.
versionUrlstringnoOptional link out to a changelog anchor (matches the vb:version-url meta tag semantics). Rendered beside the entry button, never inside it; an unsafe URL drops the link.

Security

  • Every entry url and versionUrl, and the banner's latest link, is checked against the shared sanitizer's isDangerousUrl. Script and data: URLs never reach an href or location.href.
  • swap and diff only fetch same-origin URLs. Swapped markup goes through sanitizeToFragment (the include-file fragment profile), so scripts and inline on* handlers never go live.
  • The untrusted sanitizer profile removes data-versions and data-src from any custom element, and removes every <script>. User-generated markup cannot carry a version list.

Wiring the events

Accessibility

  • Trigger: aria-haspopup="dialog", and aria-expanded tracks the open state. Its accessible name says what is being picked as well as the current value: the host's aria-label plus the version, such as API version: v2.1. The default is Version (data-label-trigger). The host itself has no role, so the label is applied to the trigger and the picker.
  • Picker: role="dialog" rendered by <pop-over> in the top layer, named like the trigger; light-dismiss via Escape and outside click. The heading (Versions or History) follows the current mode, including after a manifest loads or data-mode changes.
  • Each entry: a button whose name is its visible text: the label, any badges and the date, such as v1.4 archived last year. Author and summary sit beside the button and are linked with aria-describedby. The changelog link is a sibling of the button, never nested inside it.
  • Current entry: aria-current="true" + visual highlight; focused first when the picker opens.
  • Keyboard inside the picker: ArrowUp / ArrowDown move between entries; Home / End jump to first / last; Enter / Space activate.
  • Focus return: after the picker closes, focus returns to the trigger.
  • Banner: a labelled <aside> with a role="status" line that is filled after insertion, so it is announced.

Localisation

Every built-in string has a data-label-* override; {placeholders} are substituted. Dates use Intl.RelativeTimeFormat and Intl.DateTimeFormat with the nearest [lang].

Keys: trigger, loading, loading-versions, empty, heading-releases, heading-history, archived, draft, current, by ({author}), changelog, changelog-for ({version}), banner-label, banner ({version}), banner-latest ({version}), diff ({from}, {to}).

Attributes

AttributeTypeDefaultDescription
data-versionsstring (JSON)—Inline JSON array of version entries.
data-srcstring (URL)—URL of a JSON manifest to fetch when no inline data is provided. Falls back to <meta name="vb:versions-manifest"> if neither is set.
data-modestringderivedreleases | history — override the auto-detected mode (sets the heading; observed).
data-actionstringnavigatenavigate | swap | diff.
data-versioned-regionstring (CSS selector)noneSelector for the swappable / diffable region in this page AND in the fetched response document. Without it, the region is the first [data-versioned] element, or <main> when the page has none.
data-diff-positionstringbeforebefore | after — where to mount the diff render relative to the versioned region.
data-bannerbooleanfalseRender an archived-version warning banner above the trigger when the current entry is archived AND a non-archived "latest" exists.
data-page-info-targetstring (ID)—ID of a <page-info> to mount inside as a section in its expandable panel; the standalone trigger is hidden in this mode.
aria-labelstringVersionWhat the switcher picks; names the trigger (API version: v2.1) and the picker.
data-label-*stringEnglishString overrides; see Localisation.

Events

EventBubblesDetail
version-switcher:openyes—
version-switcher:closeyes—
version-switcher:selectyes{ entry }
version-switcher:before-navigateyes (cancellable){ entry }
version-switcher:before-swapyes (cancellable){ entry }
version-switcher:swapyes{ entry, previousId }
version-switcher:before-diffyes (cancellable){ entry }
version-switcher:diffyes{ entry, previousId, diffElement, opCount }
version-switcher:erroryes{ message, entry?, error? } — parse / fetch failures, dropped unsafe entries, cross-origin swap / diff, navigate to the current page.

JavaScript API

MemberDescription
versionsResolved version entries (read-only).
currentIdId of the current entry.
openPicker() / closePicker()Programmatic picker control.
switchTo(id)Programmatic selection — honors data-action.
refresh()Re-resolve the data source and re-render.

See also

↑