Skip to main content

Module post_connection

Module post_connection 

Source
Expand description

挿入の「post-connection steps」(HTML 標準。DOM 標準 §4.2.3 insert の手順 11)と子フレームの後始末(2026-11-27 Wave L)。

木の操作(appendChild・append・insertBefore・replaceChildren・textContent など)は、DOM の変更を すべて終えてから、挿入した部分木の <script>・<iframe>・<frame> をツリー順に 1 つずつ処理する。 そのため先に挿入された <script> からは、後ろの要素が接続済みであることは見えるが、後ろの <iframe> の contentWindow(その要素自身の post-connection の結果)はまだ見えない。

  • DomBridge は挿入のたびに対象を pending_post_connection へ積む(queue_post_connection)。
  • 関数呼び出しの後(dom_after_call)と DOM プロパティの代入の後に Interp::run_post_connection_steps を呼ぶ。 キューを丸ごと取り出してから先頭から処理するので、処理中の挿入(スクリプトが別のスクリプトを挿入する等)は 内側の呼び出しで先に完了する(Node-appendChild-three-scripts.html の s3 → s1 → s2)。
  • src の無いクラシックな <script> は同期で実行する(本文が空なら「already started」にせず、後で子が 足されたら 1 回だけ実行する)。src 付き・module などは従来どおり pending_dynamic_scripts へ渡す。
  • <iframe>/<frame> は閲覧コンテキストのある文書に繋がっていれば子文書(about:blank)を作り、 window.length・window[i] を直し、src が無い(about:blank)なら load を同期で送る。
  • 外れた枠の子文書・contentWindow は捨てる(unload/pagehide は同期で送らない)。

Constants§

FRAME_WINDOW_VAR 🔒
子フレームの文書で実行するスクリプトから、そのフレームの window のプロパティを引けるようにする一時的なグローバル名。

Functions§

is_classic_js_type 🔒
実行できるクラシックスクリプトの type(空・JavaScript の MIME)か。