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

data-emoji

Replace :shortcode: text with Unicode emoji in containers, accessible-name attributes and live in inputs. Without JavaScript, shortcodes stay as readable text.

Overview

data-emoji turns :shortcode: tokens into Unicode emoji. On a container it rewrites text nodes (no wrapping elements, no innerHTML) and the alt, title and aria-label attributes inside it. On an <input> or <textarea> it replaces each token as the user finishes typing it.

Without JavaScript, :wave: stays as readable text.

Usage

What the script does:

  1. Finds [data-emoji] elements on load, when they are inserted, and when the attribute is added to an existing element. Removing the attribute stops observe mode and live input replacement; text already replaced stays.
  2. On a container, walks its text nodes and replaces every token whose opening colon is not glued to a letter, digit or underscore, so 10:30:45, 16:9 and a:b:c are never touched. Adjacent codes such as :fire::rocket: both convert.
  3. Skips text inside <code>, <pre>, <kbd>, <samp>, <var>, <script>, <style>, <textarea>, <code-block>, contenteditable regions and [data-emoji-skip], at any depth (syntax-highlighted <pre><code><span> is safe). Only elements between the text and the container count: a container that is itself inside <code> has opted in on purpose.
  4. Converts alt, title and aria-label on the container and its descendants, with the same skip rules.
  5. Tracks enhanced elements in memory, not in an attribute, so a cloned input ("add another row") is enhanced on its own.

Options

AttributeValuesDefaultEffect
data-emoji boolean — Turns replacement on for a container, <input> or <textarea>.
data-emoji-scan once, observe once observe rescans the container 100ms after its text, children or name attributes change.
data-emoji-unknown keep, strip keep What happens to tokens with no emoji. keep leaves them. strip removes the whole token, colons and name, but only when the name contains a letter: :30: is kept. The spaces around a removed token stay, so and :nope: world becomes and  world. Containers only; inputs always keep unknown tokens.
data-emoji-skip boolean — On a descendant: leave its text and attributes alone.

Shortcodes

The core set has 209 emoji in 9 groups (Smileys, People, Animals & Nature, Food & Drink, Travel & Places, Activities, Objects, Symbols, Flags), reachable through 252 shortcodes: one canonical code each plus 43 aliases (for example :heart: for :red_heart:, :+1: for :thumbsup:). Browse them in <emoji-picker>, which shares the dataset.

Extended set

Load the extended file to add about 1,700 more shortcodes (the full gemoji GitHub/Slack set, roughly 1,640 more emoji). Load order does not matter; containers already scanned are rescanned when it arrives, and it reaches <emoji-picker> too.

SetShortcodesSize (gzipped)Where it ships
Core252 (209 emoji)about 6 KB data, 7.5 KB with the replacerInside vanilla-breeze.js, vanilla-breeze-extras.js and the autoload bundle (loaded when a [data-emoji] element first appears). Not in vanilla-breeze-core.js.
Extended (opt-in)about 1,700 moreabout 23 KBSeparate script or import

Events

No events of its own. In a focused field the replacement is an editing command, so it fires a normal input event and other listeners (data-count, autosave) see the emoji; the setRangeText() fallback fires none. Setting value from script is not processed until an input event; dispatch one to replace every token in the new value.

Styling

Nothing to style: the result is plain text in the page's font. Emoji glyphs come from the system emoji font, so they look different on each platform.

Accessibility

  • Emoji are read by name. Screen readers announce the Unicode (CLDR) name, which may not match the shortcode: :heart: is read "red heart", :+1: "thumbs up". A row of emoji is read as a row of names, so keep them few and never use one as the only carrier of meaning ("Status: ✅" should also say "done").
  • Names match the text. Shortcodes in alt, title and aria-label are converted, so the accessible name says the same as the visible text.
  • Undo works. While the field has focus, a typed replacement uses document.execCommand('insertText'), which keeps it on the undo stack: Ctrl+Z (⌘+Z) brings the shortcode back. Typing replaces only the token whose closing colon was just typed, so the restored shortcode is not replaced again by the next keystroke (pasted text is replaced throughout). Where that command is unavailable it falls back to setRangeText(), which browsers do not record for undo. Fields without a text selection (type="email", number) are rewritten directly.
  • Caret and IME. The caret stays where it was relative to the text. Replacement waits while an IME composition is active.
  • Code is left alone. Literal shortcodes in <code>, <kbd> and friends stay readable as written.

Examples

What is and is not replaced

Live input

Added later

↑