Skip to content

fix(widget): three host conditions leave a blank slot, unreported #239

Closed

Description

@Ardnived

Summary

Three host conditions leave a blank slot and nothing a volunteer can see: a module tag rewritten as a classic script, a host that patches requestIdleCallback, and client-side page translation.

Approach

  1. A stripped type="module". WordPress filters (wp_script_attributes) or optimizers that drop the type, or combine auto.js into a classic bundle, make the loader's top-level import a SyntaxError. Reproduced in the plugin's browser lane (test(browser): run the real widget in real themes, in a browser SahajAtlasWordpress#38, cell strip-module): "Cannot use import statement outside a module", empty slot. A tiny classic-script guard is impossible from inside the module, so the fix is detection: the plugin's loopback check (fix(page): the Atlas page breaks when another template renders it, unnoticed SahajAtlasWordpress#39) can read the printed tag; the widget can document the failure in docs/embedding.md's troubleshooting table.
  2. Unguarded idle callback and import. src/loader/index.ts:274-291 calls requestIdleCallback without a guard and import('../Widget') without a .catch. src/lib/embed-announce.ts:67-84 already guards the same host patch. Guard both, and log one [sahaj-atlas] line when the widget chunk fails to load.
  3. Client-side translation. Google Translate, GTranslate and Weglot's JS mode rewrite text nodes React owns, which throws removeChild/insertBefore errors and lands on the error screen. Add translate="no" to the scope root (src/Widget.tsx); the widget localises itself.

Acceptance criteria

  • A host that makes requestIdleCallback throw still gets a mounted widget.
  • A failed embed.js import logs one [sahaj-atlas] line and no unhandled rejection.
  • The scope root carries translate="no".
  • docs/embedding.md names the stripped-module failure and its symptom.

Verification checklist

  • pnpm test:run covers the loader guard with a throwing requestIdleCallback.
  • pnpm review:embed: a page with Google's translate element set to French keeps the widget working.

Notes

From the 2026-09-30 integration audit (findings C5, C6, C7).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Medium

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions