diff --git a/src/browser/frame/parse.zig b/src/browser/frame/parse.zig index 338b85916..c4251e3a8 100644 --- a/src/browser/frame/parse.zig +++ b/src/browser/frame/parse.zig @@ -95,8 +95,10 @@ pub fn fragment(frame: *Frame, node: *Node, html: []const u8, opts: FragmentPars while (it.next()) |child| { child._parent = node; } - // Nor did the options among them reach their select. + // Nor did the options among them reach their select, nor the images + // their picture. Element.Html.Select.childrenInserted(node); + try Element.Html.Picture.childrenInserted(node, frame); } // Build a detached XMLDocument from `xml` (DOMParser.parseFromString and diff --git a/src/browser/tests/element/html/image_srcset.html b/src/browser/tests/element/html/image_srcset.html index e7555a35b..4887d38bd 100644 --- a/src/browser/tests/element/html/image_srcset.html +++ b/src/browser/tests/element/html/image_srcset.html @@ -176,3 +176,40 @@ testing.expectEqual(1, loads); }); + + diff --git a/src/browser/webapi/element/html/Picture.zig b/src/browser/webapi/element/html/Picture.zig index 7ca25daeb..005c2e107 100644 --- a/src/browser/webapi/element/html/Picture.zig +++ b/src/browser/webapi/element/html/Picture.zig @@ -72,6 +72,15 @@ pub fn childRemoved(parent: *Node, child: *Node, next_sibling: ?*Node, frame: *F }; } +// parse.fragment links every child of a parent at once, so the among +// them never saw its parent. +pub fn childrenInserted(parent: *Node, frame: *Frame) !void { + if (parent.is(Picture) == null) { + return; + } + return imagesFrom(parent.firstChild(), frame); +} + pub fn sourceChanged(source: *Node, frame: *Frame) !void { const parent = source._parent orelse return; if (parent.is(Picture) == null) {