From dfc8724bc9becb34fbf61feefcbaa382f452f87c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 3 Jul 2026 09:08:07 +0000 Subject: [PATCH] fix: make module importable in DOM-free environments (Node/SSR) The package advertises a "pure DOM-free calculator" (`import { calculate }`) and index.d.ts documents calculate() as "no DOM required", plus the README claims Next.js support. But the module referenced HTMLElement (superclass), document.createElement, and customElements.define at top level, so importing it in Node/SSR threw `ReferenceError: document is not defined` at load time. The existing tests only passed because they inject a full DOM shim into globalThis before importing. Guard the three DOM touchpoints so the module loads without a browser: - derive the template's HTML into a plain string; only build the