chore(deps): update happy-dom to ^21.0.4 (#7641)

* chore(deps): update happy-dom to ^21.0.4

happy-dom 21 turns off iframe page loading by default. The player and
sdk test environments load same-origin iframe documents, so they opt
back in through their vitest happyDOM settings.

— Clippy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: adapt studio and cli tests to happy-dom 21

Studio tests load same-origin iframe documents, so they opt back in to
iframe page loading. happy-dom 21 adds Element.checkVisibility, which
reads the real styles rather than the mocked getComputedStyle, so the
motion-signature decoys are hidden in the DOM as well as in the mock.

— Clippy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(studio): fix remaining studio tests on happy-dom 21

- happy-dom now implements getAnimations, so Base UI deferred popup
  unmounts to animation frames; test setup sets Base UI's
  BASE_UI_ANIMATIONS_DISABLED, matching the old synchronous behaviour.
- happy-dom 21 drops vendor-prefixed properties it does not list, so the
  -webkit-text-fill-color tests move to a jsdom file with shared helpers.
- The scaled-iframe drag test builds its own Window, which now needs
  enableIframePageLoading.
- NLEPreview.slowBoot's per-file environment options never applied the
  disable setting and now wiped the config's iframe opt-in; drop them.

— Clippy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(studio): inline fill-test helpers instead of a shared module

Keeps the moved -webkit-text-fill-color tests self-contained and leaves
the original test file's helpers untouched.

— Clippy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(studio): drop the Base UI flag comment for the comment ratchet

— Clippy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Clippy
2026-11-13 16:56:15 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 2c2b399bfa
commit d77731aab5
12 changed files with 151 additions and 94 deletions
+8 -6
View File
@@ -14,7 +14,7 @@
"@types/node": "^25.0.10",
"esbuild": "^0.28.2",
"fallow": "^3.34.1",
"happy-dom": "^20.9.0",
"happy-dom": "^21.0.4",
"knip": "^6.0.3",
"lefthook": "^2.1.4",
"oxfmt": "^0.41.0",
@@ -320,7 +320,7 @@
},
"devDependencies": {
"@types/node": "^25.0.10",
"happy-dom": "^20.9.0",
"happy-dom": "^21.0.4",
"typescript": "^5.0.0",
"vitest": "^4.1.11",
},
@@ -1401,6 +1401,8 @@
"buffer-from": ["buffer-from@1.1.2", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="],
"buffer-image-size": ["buffer-image-size@0.6.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ=="],
"bun-types": ["bun-types@1.3.13", "", { "dependencies": { "@types/node": "*" } }, "sha512-QXKeHLlOLqQX9LgYaHJfzdBaV21T63HhFJnvuRCcjZiaUDpbs5ED1MgxbMra71CsryN/1dAoXuJJJwIv/2drVA=="],
"bundle-name": ["bundle-name@4.1.0", "", { "dependencies": { "run-applescript": "^7.0.0" } }, "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q=="],
@@ -1683,7 +1685,7 @@
"gtoken": ["gtoken@7.1.0", "", { "dependencies": { "gaxios": "^6.0.0", "jws": "^4.0.0" } }, "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw=="],
"happy-dom": ["happy-dom@20.9.0", "", { "dependencies": { "@types/node": ">=20.0.0", "@types/whatwg-mimetype": "^3.0.2", "@types/ws": "^8.18.1", "entities": "^7.0.1", "whatwg-mimetype": "^3.0.0", "ws": "^8.18.3" } }, "sha512-GZZ9mKe8r646NUAf/zemnGbjYh4Bt8/MqASJY+pSm5ZDtc3YQox+4gsLI7yi1hba6o+eCsGxpHn5+iEVn31/FQ=="],
"happy-dom": ["happy-dom@21.0.4", "", { "dependencies": { "@types/node": ">=20.0.0", "@types/whatwg-mimetype": "^3.0.2", "@types/ws": "^8.18.1", "buffer-image-size": "^0.6.4", "entities": "^7.0.1", "whatwg-mimetype": "^3.0.0", "ws": "^8.21.0" } }, "sha512-tFm+GaLBgo6o0awHnvHaNoraVo27qJ+2tZEtZ+cIa08hXbeitrxAJajLI05hsUy/2/YTKcUjQYzHe5mCcraLBw=="],
"has-flag": ["has-flag@4.0.0", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],
@@ -2199,7 +2201,7 @@
"wrappy": ["wrappy@1.0.2", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="],
"ws": ["ws@8.20.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA=="],
"ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="],
"wsl-utils": ["wsl-utils@0.1.0", "", { "dependencies": { "is-wsl": "^3.1.0" } }, "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw=="],
@@ -2271,6 +2273,8 @@
"@google-cloud/storage/google-auth-library": ["google-auth-library@9.15.1", "", { "dependencies": { "base64-js": "^1.3.0", "ecdsa-sig-formatter": "^1.0.11", "gaxios": "^6.1.1", "gcp-metadata": "^6.1.0", "gtoken": "^7.0.0", "jws": "^4.0.0" } }, "sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng=="],
"@google/genai/ws": ["ws@8.20.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA=="],
"@img/sharp-wasm32/@emnapi/runtime": ["@emnapi/runtime@1.11.3", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA=="],
"@isaacs/cliui/string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="],
@@ -2357,8 +2361,6 @@
"path-scurry/minipass": ["minipass@7.1.3", "", {}, "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A=="],
"puppeteer-core/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="],
"recast/source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
"sharp/semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="],
+1 -1
View File
@@ -76,7 +76,7 @@
"@types/node": "^25.0.10",
"esbuild": "^0.28.2",
"fallow": "^3.34.1",
"happy-dom": "^20.9.0",
"happy-dom": "^21.0.4",
"knip": "^6.0.3",
"lefthook": "^2.1.4",
"oxfmt": "^0.41.0",
@@ -771,7 +771,7 @@ describe("motion-signature.browser counter channel", () => {
it("ignores a display:none decoy counter owner in a frozen composition", () => {
document.body.innerHTML = `
<div id="root" data-composition-id="main" data-width="640" data-height="360">
<div id="decoy"></div>
<div id="decoy" style="display: none"></div>
<span id="countdown"></span>
</div>
`;
@@ -799,7 +799,7 @@ describe("motion-signature.browser counter channel", () => {
it("ignores a decoy counter owner nested inside a display:none subtree", () => {
document.body.innerHTML = `
<div id="root" data-composition-id="main" data-width="640" data-height="360">
<div id="hidden-parent"><div id="decoy"></div></div>
<div id="hidden-parent" style="display: none"><div id="decoy"></div></div>
<span id="countdown"></span>
</div>
`;
+1
View File
@@ -29,6 +29,7 @@ export default defineConfig({
happyDOM: {
settings: {
handleDisabledFileLoadingAsSuccess: true,
enableIframePageLoading: true,
navigator: {
userAgent:
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.0.0 Safari/537.36",
+1 -1
View File
@@ -90,7 +90,7 @@
},
"devDependencies": {
"@types/node": "^25.0.10",
"happy-dom": "^20.9.0",
"happy-dom": "^21.0.4",
"typescript": "^5.0.0",
"vitest": "^4.1.11"
}
+3
View File
@@ -4,5 +4,8 @@ export default defineConfig({
test: {
include: ["src/**/*.test.ts"],
environment: "node",
environmentOptions: {
happyDOM: { settings: { enableIframePageLoading: true } },
},
},
});
@@ -0,0 +1,129 @@
// @vitest-environment jsdom
// happy-dom drops the vendor-prefixed fill property these tests assert on.
import { afterEach, describe, expect, it, vi } from "vitest";
import { applyInlineStyle } from "./inlineTextStyleRange";
afterEach(() => {
vi.restoreAllMocks();
document.body.innerHTML = "";
});
function mount(html: string): HTMLElement {
document.body.innerHTML = `<h1>${html}</h1>`;
return document.body.firstElementChild as HTMLElement;
}
/** Every text node and line break in order, with the offset each one starts at. */
function charSpans(host: HTMLElement): Array<{ node: Node; from: number; length: number }> {
const spans: Array<{ node: Node; from: number; length: number }> = [];
const walker = document.createTreeWalker(host, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
let seen = 0;
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
const isBreak = node.nodeType === 1 && (node as Element).tagName === "BR";
if (node.nodeType === 1 && !isBreak) continue;
const length = isBreak ? 1 : (node.textContent?.length ?? 0);
spans.push({ node, from: seen, length });
seen += length;
}
return spans;
}
/**
* A range over the host's text, by character offsets across the whole element.
*
* A line break counts as one character, the same way the module does, but is
* never landed on: a boundary there belongs to the text beside it, which is
* where a real selection would put it too.
*/
function rangeOver(host: HTMLElement, start: number, end: number): Range {
const range = document.createRange();
const text = charSpans(host).filter((span) => span.node.nodeType === 3);
const at = (offset: number) => text.find((span) => span.from + span.length >= offset);
const from = at(start);
const to = at(end);
if (from) range.setStart(from.node, start - from.from);
if (from && to) range.setEnd(to.node, end - to.from);
return range;
}
/**
* A colour that does not paint is the same to the user as one that did not save.
*
* `-webkit-text-fill-color` inherits and paints the glyph fill, so a composition
* that sets it on a text element wins over any `color` the editor puts on a run
* inside it. The run saved correctly and rendered in someone else's colour,
* which reads as the colour picker being broken.
*/
describe("applyInlineStyle when something else is painting the glyphs", () => {
function stubFill(fill: string | null | ((element: HTMLElement) => string | null)) {
const real = window.getComputedStyle.bind(window);
vi.spyOn(window, "getComputedStyle").mockImplementation(((element: Element) => {
const computed = real(element as HTMLElement);
const resolvedFill = typeof fill === "function" ? fill(element as HTMLElement) : fill;
return new Proxy(computed, {
get: (target, key) => {
if (key === "webkitTextFillColor") return resolvedFill ?? undefined;
if (key === "color") return (element as HTMLElement).style.color || "rgb(0, 0, 0)";
return Reflect.get(target, key);
},
});
}) as typeof window.getComputedStyle);
}
it("mirrors the colour into the fill when an ancestor is overpainting", () => {
const host = mount("Hello world");
stubFill("rgb(255, 255, 255)");
applyInlineStyle(rangeOver(host, 6, 11), { color: "rgb(255, 0, 149)" });
expect(host.innerHTML).toContain("-webkit-text-fill-color: rgb(255, 0, 149)");
expect(host.innerHTML).toContain("color: rgb(255, 0, 149)");
});
it("leaves the markup alone when nothing is overpainting", () => {
const host = mount("Hello world");
stubFill("rgb(255, 0, 149)");
applyInlineStyle(rangeOver(host, 6, 11), { color: "rgb(255, 0, 149)" });
expect(host.innerHTML).not.toContain("-webkit-text-fill-color");
expect(host.innerHTML).toContain("color: rgb(255, 0, 149)");
});
it("says nothing about a run that carries no colour", () => {
const host = mount("Hello world");
stubFill("rgb(255, 255, 255)");
applyInlineStyle(rangeOver(host, 6, 11), { "font-weight": "700" });
expect(host.innerHTML).not.toContain("-webkit-text-fill-color");
});
it("mirrors only the run whose own ancestor path is overpainting", () => {
const host = mount(
'<span data-hf-text-key="child:0" style="color: blue">left</span>' +
'<span data-hf-text-key="child:1" style="color: green">right</span>',
);
stubFill((element) =>
element.textContent === "left" ? "rgb(255, 255, 255)" : element.style.color,
);
applyInlineStyle(rangeOver(host, 4, 9), { color: "red" });
const [left, right] = Array.from(host.querySelectorAll<HTMLElement>("span"));
expect(left?.style.getPropertyValue("-webkit-text-fill-color")).toBe("blue");
expect(right?.style.getPropertyValue("-webkit-text-fill-color")).toBe("");
});
it("drops a generated mirror when the ancestor stops overpainting", () => {
const host = mount("Hello world");
let overpainted = true;
stubFill((element) => (overpainted ? "rgb(255, 255, 255)" : element.style.color));
applyInlineStyle(rangeOver(host, 6, 11), { color: "red" });
expect(host.innerHTML).toContain("-webkit-text-fill-color");
overpainted = false;
const live = document.getSelection()?.getRangeAt(0);
if (live) applyInlineStyle(live, { "font-weight": "700" });
expect(host.innerHTML).not.toContain("-webkit-text-fill-color");
});
});
@@ -621,88 +621,6 @@ describe("applyInlineStyle survives a control that fires repeatedly", () => {
expect(document.getSelection()?.toString()).toBe("cde");
});
});
/**
* A colour that does not paint is the same to the user as one that did not save.
*
* `-webkit-text-fill-color` inherits and paints the glyph fill, so a composition
* that sets it on a text element wins over any `color` the editor puts on a run
* inside it. The run saved correctly and rendered in someone else's colour,
* which reads as the colour picker being broken.
*/
describe("applyInlineStyle when something else is painting the glyphs", () => {
function stubFill(fill: string | null | ((element: HTMLElement) => string | null)) {
const real = window.getComputedStyle.bind(window);
vi.spyOn(window, "getComputedStyle").mockImplementation(((element: Element) => {
const computed = real(element as HTMLElement);
const resolvedFill = typeof fill === "function" ? fill(element as HTMLElement) : fill;
return new Proxy(computed, {
get: (target, key) => {
if (key === "webkitTextFillColor") return resolvedFill ?? undefined;
if (key === "color") return (element as HTMLElement).style.color || "rgb(0, 0, 0)";
return Reflect.get(target, key);
},
});
}) as typeof window.getComputedStyle);
}
it("mirrors the colour into the fill when an ancestor is overpainting", () => {
const host = mount("Hello world");
stubFill("rgb(255, 255, 255)");
applyInlineStyle(rangeOver(host, 6, 11), { color: "rgb(255, 0, 149)" });
expect(host.innerHTML).toContain("-webkit-text-fill-color: rgb(255, 0, 149)");
expect(host.innerHTML).toContain("color: rgb(255, 0, 149)");
});
it("leaves the markup alone when nothing is overpainting", () => {
const host = mount("Hello world");
stubFill("rgb(255, 0, 149)");
applyInlineStyle(rangeOver(host, 6, 11), { color: "rgb(255, 0, 149)" });
expect(host.innerHTML).not.toContain("-webkit-text-fill-color");
expect(host.innerHTML).toContain("color: rgb(255, 0, 149)");
});
it("says nothing about a run that carries no colour", () => {
const host = mount("Hello world");
stubFill("rgb(255, 255, 255)");
applyInlineStyle(rangeOver(host, 6, 11), { "font-weight": "700" });
expect(host.innerHTML).not.toContain("-webkit-text-fill-color");
});
it("mirrors only the run whose own ancestor path is overpainting", () => {
const host = mount(
'<span data-hf-text-key="child:0" style="color: blue">left</span>' +
'<span data-hf-text-key="child:1" style="color: green">right</span>',
);
stubFill((element) =>
element.textContent === "left" ? "rgb(255, 255, 255)" : element.style.color,
);
applyInlineStyle(rangeOver(host, 4, 9), { color: "red" });
const [left, right] = Array.from(host.querySelectorAll<HTMLElement>("span"));
expect(left?.style.getPropertyValue("-webkit-text-fill-color")).toBe("blue");
expect(right?.style.getPropertyValue("-webkit-text-fill-color")).toBe("");
});
it("drops a generated mirror when the ancestor stops overpainting", () => {
const host = mount("Hello world");
let overpainted = true;
stubFill((element) => (overpainted ? "rgb(255, 255, 255)" : element.style.color));
applyInlineStyle(rangeOver(host, 6, 11), { color: "red" });
expect(host.innerHTML).toContain("-webkit-text-fill-color");
overpainted = false;
const live = document.getSelection()?.getRangeAt(0);
if (live) applyInlineStyle(live, { "font-weight": "700" });
expect(host.innerHTML).not.toContain("-webkit-text-fill-color");
});
});
describe("readInlineStyleSpread", () => {
it("reports every distinct colour in the selection, in order", () => {
const host = mount(
@@ -128,7 +128,7 @@ describe("measureManualOffsetDragScreenToOffsetMatrix", () => {
});
it("measures movement in parent viewport pixels when the element is inside a scaled iframe", () => {
const window = new Window();
const window = new Window({ settings: { enableIframePageLoading: true } });
const iframe = window.document.createElement("iframe");
window.document.body.append(iframe);
const iframeWindow = iframe.contentWindow;
@@ -1,5 +1,4 @@
// @vitest-environment happy-dom
// @vitest-environment-options {"happyDOM":{"settings":{"disableIframePageLoading":true}}}
import React, { act, createRef } from "react";
import { createRoot } from "react-dom/client";
+2
View File
@@ -12,3 +12,5 @@ if (typeof CSS.escape !== "function") {
if (typeof globalThis.confirm !== "function") {
(globalThis as Record<string, unknown>).confirm = () => false;
}
(globalThis as Record<string, unknown>).BASE_UI_ANIMATIONS_DISABLED = true;
+3
View File
@@ -411,5 +411,8 @@ export default defineConfig({
test: {
exclude: ["data/**", "node_modules/**"],
setupFiles: ["src/test-setup.ts"],
environmentOptions: {
happyDOM: { settings: { enableIframePageLoading: true } },
},
},
});