Files
airship/packages
Nayan 10bfae876a fix(overlay): give a nested same-origin document its own surface
Picking inside a nested same-origin iframe — a Storybook preview is the
one everyone hits — selected the <iframe> itself: the hit test stopped at
the first document, and a node from a nested document belonged to no
surface, so selection bailed before it began. Reported in #17 by
nikbrunner, whose diagnosis (recursive elementFromPoint; each iframe's
rect already in its parent's coordinates, so scale composes only at the
outer boundary) this follows.

Rather than teaching FrameSurface to carry foreign nodes — too much of
the editor reads surface.doc expecting the node's own document — a nested
document becomes its own Surface. NestedSurface keeps `doc` honest, so
the marquee, drag ghost, DOM tree and every other within-one-document
consumer keep working untouched; only the coordinate methods compose the
iframe chain (re-derived per call, since an HMR reload replaces the
elements with no event), bounds() clips to the nested viewport, and
extract/scanTokens route to the nested document's own agent.

The resolvers do the walking: at() steps into the same-origin iframe
under the point up to MAX_NEST_DEPTH deep, of() rides frameOf's chain
walk, and nested surfaces cache weakly per document so the picker's
identity comparisons hold. Inline mode gets the same descent with the
page as root — no agent there, deliberately, since the proxy passes
third-party iframes through under inline. A cross-origin boundary stays
an opaque leaf, exactly today's behaviour. The one shared hitTestIn keeps
the drag-proxy filter in a single place; its six regression cases are
untouched and green.
2026-08-16 13:05:37 +05:30
..