Keep your coding agent up to date with the latest web best practices
Release v0.0.130
github-actions[bot]945de44b6b5c
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 74a92c1..fb1fff1 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.129"+ "version": "0.0.130"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 58e6657..9f29d2a 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.129",+ "version": "0.0.130","author": {"name": "Google Chrome"}diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.jsonindex 58e6657..9f29d2a 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.129",+ "version": "0.0.130","author": {"name": "Google Chrome"}diff --git a/README.md b/README.mdindex 2292f88..94ff03b 100644--- a/README.md+++ b/README.md@@ -36,7 +36,7 @@ Here's a tiny sampling of the **134+ 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.129)+#### Full Skill Coverage (v0.0.130)<details><summary>Includes expert guidance across <strong>94 modern web features</strong></summary>diff --git a/gemini-extension.json b/gemini-extension.jsonindex 58e6657..9f29d2a 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.129",+ "version": "0.0.130","author": {"name": "Google Chrome"}diff --git a/package.json b/package.jsonindex 456a048..e9fd0c8 100644--- a/package.json+++ b/package.json@@ -2,7 +2,7 @@"name": "modern-web-guidance","displayName": "Modern Web Guidance","description": "Keep your agent up to date on the latest web best practices.",- "version": "0.0.129",+ "version": "0.0.130","publisher": "GoogleChrome","engines": {"vscode": "^1.90.0",diff --git a/skills/modern-web-guidance/guides/user-experience/declarative-dialog-popover-control.md b/skills/modern-web-guidance/guides/user-experience/declarative-dialog-popover-control.mdindex 66c37b8..6fd73b2 100644--- a/skills/modern-web-guidance/guides/user-experience/declarative-dialog-popover-control.md+++ b/skills/modern-web-guidance/guides/user-experience/declarative-dialog-popover-control.md@@ -29,7 +29,7 @@ If you need to control opening and closing with separate buttons, you can use thShow Popover</button>-<div id="my-explicit-popover" popover>+<div id="my-explicit-popover" popover="manual"><p>This popover is explicitly opened and closed by separate buttons.</p><!-- MANDATORY: Use 'hide-popover' to explicitly close the targeted popover. -->@@ -70,9 +70,10 @@ Because Invoker Commands and Popovers are not yet universally supported, you MUS### Polyfilling Invoker CommandsMANDATORY: Feature detect support by checking for the `commandForElement` property on the `HTMLButtonElement` prototype. Do NOT check the window or document object. You MUST dynamically import the polyfill only when the native feature is missing. DO NOT unconditionally load the polyfill.+Mandatory: Listen for the 'command' event directly on the target element because the native 'command' event does not bubble.-**Option 1: Using a package manager (e.g., npm)**-Install the polyfill in your project (`npm install invokers-polyfill`).+**Option 1: Using a bundler**+Install the polyfill via npm (`npm install invokers-polyfill`). This approach is for projects using a bundler (like Vite or Webpack) or import maps. For all other setups, use the CDN option below.```javascript// MANDATORY: Feature detect 'commandForElement' on HTMLButtonElement.prototype.@@ -82,23 +83,90 @@ if (!('commandForElement' in HTMLButtonElement.prototype)) {}```-**Option 2: Manual installation without npm**-If you are not using a package manager, dynamically import the polyfill directly from a CDN (such as unpkg) inside a `<script type="module">`.+**Option 2: Using a CDN**+For projects without a bundler, dynamically import the polyfill directly from a CDN inside a `<script type="module">`.```html<script type="module">// MANDATORY: Feature detect 'commandForElement' on HTMLButtonElement.prototype.// Conditionally load the invokers-polyfill from a CDN only in browsers lacking native support.if (!('commandForElement' in HTMLButtonElement.prototype)) {- import('https://unpkg.com/invokers-polyfill@latest/invoker.min.js');+ import('https://esm.run/invokers-polyfill');}</script>```**Invokers Polyfill Limitations**-Unlike the native Invoker Commands API, `invokers-polyfill` does not automatically handle ARIA attributes (such as `aria-expanded`) on the command button.+MANDATORY: This polyfill does not handle the ARIA states (e.g., `aria-expanded`) of the command button the way native browsers do. You are strongly encouraged to handle these states yourself to ensure your site is fully accessible.-MANDATORY: You MUST manually manage these ARIA states to ensure your site remains fully accessible to screen readers in browsers relying on the polyfill.+Baseline status for Invoker commands: Newly available. It's been Baseline since 2025-12-12.++If the Invoker Commands API is not supported, the `command` event will not fire. For full support across all modern browsers, it is recommended to use the invokers-polyfill from https://github.com/keithamus/invokers-polyfill via `npm install` or CDN.++This polyfill fully supports custom actions (starting with `--`) and dispatches the `command` event exactly like the native API.++### Dynamic Import (Performance Optimization)++For the best performance, you should only load the polyfill if the browser doesn't support the API natively. This saves bandwidth and reduces script execution time for users on modern browsers.++```javascript+// Check for native support first+const hasNativeSupport = 'commandForElement' in HTMLButtonElement.prototype;++if (!hasNativeSupport) {+ // Dynamically import the polyfill only when needed+ try {+ await import('https://cdn.jsdelivr.net/npm/invokers-polyfill@latest/dist/index.min.js');+ console.log('Invoker Commands polyfill loaded');+ } catch (err) {+ console.error('Error loading fallback:', err);+ }+}+```++### Manual fallback (Traditional pattern)++If you prefer not to use a polyfill, you can use a combination of **event delegation** to dispatch events and a **command registry** to handle the actions. This is a common architectural pattern in traditional JavaScript development that remains highly efficient and scalable.++```javascript+// 1. Define a registry of requested actions for cleaner logic+const commandRegistry = {+ '--spin': (target) => target.classList.toggle('is-spun'),+ '--grow': (target) => target.classList.toggle('is-grown'),+ '--reset': (target) => target.classList.remove('is-spun', 'is-grown'),+};++const supportsInvokers = 'commandForElement' in HTMLButtonElement.prototype;++// 2. The fallback: Dispatch events manually if native support is missing+if (!supportsInvokers) {+ document.addEventListener('click', (event) => {+ const button = event.target.closest('button[commandfor]');+ if (!button) return;++ const target = document.getElementById(button.getAttribute('commandfor'));+ const command = button.getAttribute('command');++ if (target && command) {+ target.dispatchEvent(new CustomEvent('command', {+ bubbles: true,+ detail: { command }+ }));+ }+ });+}++// 3. The unified listener: Registered directly on the target element+document.getElementById('action-target').addEventListener('command', (event) => {+ const command = event.command || event.detail?.command;+ const target = event.currentTarget;+ const action = commandRegistry[command];++ if (action) {+ action(target);+ }+});+```### Polyfilling the Popover Attribute@@ -106,8 +174,8 @@ To support the `popover` attribute in older browsers, use the `@oddbird/popover-MANDATORY: Feature detect popover support by checking for the `popover` property on the `HTMLElement` prototype. Conditionally initialize the polyfill only if native support is missing.-**Option 1: Using a package manager**-Install the package (`npm install @oddbird/popover-polyfill`).+**Option 1: Using a bundler**+Install the package via npm (`npm install @oddbird/popover-polyfill`). This method requires a bundler or import maps to resolve the module path.```javascript// MANDATORY: Feature detect 'popover' on HTMLElement.prototype.@@ -118,8 +186,8 @@ if (!('popover' in HTMLElement.prototype)) {}```-**Option 2: Manual installation without npm**-If you are not using a package manager, dynamically import the polyfill directly from a CDN (such as unpkg) inside a `<script type="module">`.+**Option 2: Using a CDN**+For projects without a bundler, dynamically import the polyfill directly from a CDN inside a `<script type="module">`.```html<script type="module">