minor, webapi: Prevent outerHTML of document's element's from being written

Captured by WPT test: /domparsing/outerhtml-01.html
This commit is contained in:
Karl Seguin
2026-07-13 12:52:38 +08:00
parent 0ff08420c8
commit e4387bf7fa

View File

@@ -466,6 +466,11 @@ pub fn setOuterHTML(self: *Element, html: []const u8, frame: *Frame) !void {
const node = self.asNode();
const parent = node._parent orelse return;
// The parent of a documentElement is the Document, which cannot be modified.
if (parent._type == .document) {
return error.NoModificationAllowed;
}
frame.domChanged();
if (html.len > 0) {
const fragment = (try Node.DocumentFragment.init(frame)).asNode();