前端前線 2026 年 8 月 26 日

2026-08-26 — WHATWG 將 XSLT 標記為棄用,並修正同源導覽 active document 更新時機

primary=https://github.com/whatwg/html/commit/208004fb0c299e2d2a24e973ec7bd35bc888add9 primary=https://github.com/whatwg/html/commit/a2d61eccfd9751e2f64a94eed280a57fa6d48be7 primary=https://github.com/whatwg/html/issues/11523 primary=https://html.spec.whatwg.org/multipage/document-sequences.html#active-document

WHATWG 將 XSLT 標記為正式棄用,並修正同源導覽時 active document 的更新時機

github.com/whatwg/html · 2026-08-25

WHATWG 於 2026-08-25 對 HTML 標準原始碼倉庫 whatwg/html 送出兩個獨立的規格修訂。commit 208004f 由 mfreed7 提交,將用戶端 XSLT 正式標記為棄用;commit a2d61ec 由 shannonbooth 提交,修正 browsing context 在同源導覽時過早更新 active document 的時序問題。兩者都只是規格文字層級的修訂,尚未對應任何瀏覽器的行為變更。

背景:XSLT 為何走向淘汰

mfreed7 於 2025 年 8 月在 issue #11523 提出移除 XSLT 的討論,該議題目前標記為 stage: 3 - Committed。主要理由是各家瀏覽器至今僅實作 1999 年版的 XSLT 1.0,而底層實作(例如 Chromium 採用的 libxslt)是老舊的 C/C++ 程式庫,長年是記憶體安全漏洞的來源,獲得的維護與安全審查資源也遠不如 JavaScript 引擎。

與此同時,JSON 搭配 React、Vue 等框架已經取代大多數用戶端轉換的應用場景,client-side XSLT 的實際使用率持續下滑。Chrome、Firefox、WebKit 三個引擎目前都已表態計畫將其自各自實作中移除,規格層級的棄用聲明是這個多年流程的第一步。

規格細節:三處新增棄用警告

commit 208004f 在規格中三個章節加入完全相同的 class="critical" 等級警告,分別是:

  • Interactions with XPath and XSLT
  • Interaction of script elements and XSLT
  • Interaction of template elements with XSLT and XPath

三處插入的警告文字完全一致:

Avoid using client-side XSLT in browsers. The browser
implementations of XSLT are highly susceptible to memory
safety vulnerabilities, and the web platform has evolved
toward JavaScript as the safe replacement. For these reasons,
this feature is in the process of being removed from the web
platform. (This is a long process that takes many years.)

規格本身特別註明這是「需要數年」的長期移除過程,目前僅為文字層級的棄用聲明,並未變更任何 XSLT 解析或轉換行為,也沒有附帶 Web IDL 或相容性資料表的調整。

背景:active document 與 make active 演算法

在 HTML 規格中,browsing context 的 active document 代表目前呈現給使用者的 Document;navigable 的 active document 則定義為其 active session history entry 所對應的文件,而 active window 是 active document 的 relevant global object。修訂前,browsing context 的 active document 並非獨立欄位,而是由規格文字動態推導:「其 active window 的 associated Document」。

這種即時推導的寫法意味著,只要 active window 所關聯的 document 指標一變,active document 就會立刻跟著變,而不必等到規格中真正代表「文件已生效」的 make active 演算法執行完畢。在同源導覽的初始化階段,新文件往往會先被暫時關聯到 window 上,這就讓 active document 在文件尚未真正被啟用前就提前指向了它。

規格細節:改為顯式屬性,只由 make active 更新

commit a2d61ec(+6/-3 行,基於前一個 commit 224e47e)把 active document 從「推導定義」改成 browsing context 上一個顯式儲存的欄位,並刪除舊有的推導句子:

- A browsing context's active document is its active window's
-   associated Document.

+ active document
+   A Document or null, initially null.

+ (in the "make active" algorithm)
+ Set document's browsing context's active document to document.

改動後,active document 只會在 make active 演算法明確執行到「設定 active document」這一步時才更新,不再因為 active window 關聯文件的變化而提前切換。commit 訊息指出,這修正了同源導覽時序過早更新的問題,避免規格中依賴 active document 判斷「文件是否已生效」的其他演算法在錯誤的時間點讀到尚未真正啟用的新文件。

影響範圍

兩個改動目前都只影響 WHATWG HTML 規格文字本身,尚未對應任何瀏覽器發行版本:

  • XSLT 棄用聲明不會改變 Chromium、Firefox、WebKit 目前的實際行為,各引擎的實際移除時程仍需各自另行公告。
  • active document 時序修正屬於規格內部一致性修補,主要影響依循規格實作 browsing context、iframe 與同源導覽演算法的瀏覽器引擎工程師,以及其他引用此定義的規格文件。

兩個 commit 都於 2026-08-25 合併進 whatwg/html 的 main 分支,均未附帶對應的瀏覽器相容性資料或測試變更,屬於規格編輯層級的修訂。

原始來源:commit 208004fcommit a2d61ecissue #11523HTML Standard §active document


End of article
0
Would love your thoughts, please comment.x
()
x