Keep your coding agent up to date with the latest web best practices
Release v0.0.145
github-actions[bot]482ca11583ff
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 3280c07..bc93e96 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -8,7 +8,7 @@"name": "modern-web-guidance","source": "./","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.144"+ "version": "0.0.145"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex c5d0034..18e6362 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.144",+ "version": "0.0.145","author": {"name": "Google Chrome"}diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.jsonindex c5d0034..18e6362 100644--- a/.cursor-plugin/plugin.json+++ b/.cursor-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.144",+ "version": "0.0.145","author": {"name": "Google Chrome"}diff --git a/README.md b/README.mdindex 1cd4904..5c9c4b4 100644--- a/README.md+++ b/README.md@@ -36,7 +36,7 @@ Here's a tiny sampling of the **123 use-case-centric guides**:* **Accessibility & Security**: accessible error announcements, keyboard focus management.* **Built-in AI**: Leveraging local, on-device client models (native Language Detection, Summarization, and Translation APIs).-#### Full Skill Coverage (v0.0.144)+#### Full Skill Coverage (v0.0.145)<details><summary>Includes expert guidance across <strong>98 modern web features</strong></summary>@@ -157,7 +157,7 @@ Here's a tiny sampling of the **123 use-case-centric guides**:<h3>css</h3>-- **[css-custom-highlights](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/css-custom-highlights.md)**: Highlight arbitrary text ranges on a page without modifying the DOM, using the CSS Custom Highlight API. For example, highlighting search results, spelling errors, or collaborative editing cursors.+- **[highlight-text-ranges](https://github.com/GoogleChrome/modern-web-guidance/blob/main/skills/modern-web-guidance/guides/css/highlight-text-ranges.md)**: Highlight arbitrary text ranges on a page such as search results, spelling errors, or collaborative editing cursors.<h3>forms</h3>diff --git a/gemini-extension.json b/gemini-extension.jsonindex c5d0034..18e6362 100644--- a/gemini-extension.json+++ b/gemini-extension.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Keep your coding agent up to date with the latest web best practices",- "version": "0.0.144",+ "version": "0.0.145","author": {"name": "Google Chrome"}diff --git a/package.json b/package.jsonindex 0ede9d7..2ff3eac 100644--- a/package.json+++ b/package.json@@ -3,7 +3,7 @@"displayName": "Modern Web Guidance","description": "Keep your agent up to date on the latest web best practices.","license": "Apache-2.0",- "version": "0.0.144",+ "version": "0.0.145","publisher": "GoogleChrome","engines": {"vscode": "^1.90.0",diff --git a/skills/modern-web-guidance/guides/css/css-custom-highlights.md b/skills/modern-web-guidance/guides/css/highlight-text-ranges.mdsimilarity index 83%rename from skills/modern-web-guidance/guides/css/css-custom-highlights.mdrename to skills/modern-web-guidance/guides/css/highlight-text-ranges.mdindex 73cb90d..d525357 100644--- a/skills/modern-web-guidance/guides/css/css-custom-highlights.md+++ b/skills/modern-web-guidance/guides/css/highlight-text-ranges.md@@ -79,12 +79,12 @@ Custom highlights are purely presentational and are not exposed to the accessibiHighlights should not rely solely on color to convey meaning. If a highlight indicates an error, pair it with another visual indicator such as `text-decoration: wavy underline` or an adjacent text label. Ensure sufficient contrast between the highlight background and text color to meet WCAG 2.1 requirements (at least 4.5:1 for normal text).### Fallback strategies+Baseline status for Custom highlights: Newly available. It's been Baseline since 2026-03-24.Supported by: Chrome 105 (Sep 2022), Edge 105 (Sep 2022), Firefox 149 (Mar 2026), and Safari 17.2 (Dec 2023).For browsers that do not support the CSS Custom Highlight API, you should provide a functional base experience where text is still legible, even without the visual highlight.-#### Feature detectionYou can detect support before using the API:```javascript@@ -95,18 +95,34 @@ if (CSS.highlights) {}```-#### DOM-based fallback-If the highlight is critical for the user experience, fall back to wrapping matched text in `<mark>` elements. This modifies the DOM, so take care to preserve event listeners and avoid breaking the document structure.```javascriptif (!CSS.highlights) {- // IMPORTANT: Escape user input to prevent XSS when using innerHTML.- const escaped = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");- const regex = new RegExp(`(${escaped})`, "gi");- article.innerHTML = article.textContent.replace(- regex,- "<mark>$1</mark>"- );+ // Walk text nodes and wrap matches in <mark>, preserving structure.+ const walker = document.createTreeWalker(article, NodeFilter.SHOW_TEXT);+ const nodes = [];+ for (let n = walker.nextNode(); n; n = walker.nextNode()) nodes.push(n);++ const term = searchTerm.toLowerCase();+ for (const textNode of nodes) {+ const text = textNode.textContent;+ let pos = text.toLowerCase().indexOf(term);+ if (pos === -1) continue;++ const frag = document.createDocumentFragment();+ let last = 0;+ while (pos !== -1) {+ frag.append(text.slice(last, pos));+ const mark = document.createElement("mark");+ // textContent assignment avoids HTML injection.+ mark.textContent = text.slice(pos, pos + term.length);+ frag.append(mark);+ last = pos + term.length;+ pos = text.toLowerCase().indexOf(term, last);+ }+ frag.append(text.slice(last));+ textNode.replaceWith(frag);+ }}```