mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(studio): realm-safe isHTMLElement so timeline z-index commits land
applyTimelineStackingReorder resolves the live clip from the preview IFRAME,
then gated it with `element instanceof HTMLElement` against the MAIN window's
constructor. Cross-realm instanceof is always false, so every timeline z-index
commit silently bailed ("element not live in iframe") — the drag resolved the
right z but never wrote it. Use the element's own-realm HTMLElement constructor
(matching timelineDOM.ts). Verified end-to-end: dragging a card down now lowers
its z-index and reorders the row, leaving sibling z-indexes untouched.
Unit tests missed this because the happy-dom test iframe shares a realm; caught
via a real-browser Puppeteer E2E drag.
This commit is contained in:
@@ -12,7 +12,12 @@ import type { EditHistoryKind } from "../utils/editHistory";
|
||||
import type { TimelineZIndexReorderCommit } from "./useTimelineEditingTypes";
|
||||
|
||||
function isHTMLElement(element: Element | null): element is HTMLElement {
|
||||
return element != null && element instanceof HTMLElement;
|
||||
if (!element) return false;
|
||||
// Use the element's OWN realm's HTMLElement: timeline clips live in the preview
|
||||
// iframe, and cross-realm `element instanceof HTMLElement` (main window) is
|
||||
// always false — which silently dropped every timeline z-index commit.
|
||||
const Ctor = element.ownerDocument?.defaultView?.HTMLElement ?? globalThis.HTMLElement;
|
||||
return element instanceof Ctor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user