v158 · dom · composition

Live preview through the handle

The explainer keeps the opener relationship on purpose: a design or coding tool can put its editor in one half of a split and a real top-level preview in the other (own viewport, no iframe restrictions), then drive it through the handle window.open() returned. This page is that editor. It also shows the other side of the contract: split,noopener gives you no handle, a named pane is re-used, and handle.close() collapses the split.

Checking this browser…

Editor

Preview state: not open

The open call: window.open("…/pane.html?mode=preview", "sts-live-preview", "popup=0,split,splitposition=right,splitsize=40")

the code

const pane = window.open("/preview", "sts-live-preview",
  "popup=0,split,splitposition=right,splitsize=40");
if (!pane) showInlineFallback();          // blocked: say so, don't pretend

editor.addEventListener("input", () =>
  pane.postMessage({ type: "source", title, body }, location.origin));

window.open("", "sts-live-preview") === pane;   // named re-use, no new split
window.open(url, "_blank", "split,noopener");   // → null: no handle at all
pane.close();                                   // collapses the split

Things the editor still cannot do: learn whether the pane is a split or a tab, read its size from the browser, or resize the split later — splitposition/splitsize apply at open time only. The preview reports its own innerWidth in each acknowledgement, which is ordinary viewport information it could always send.

see also