From db64ced3fbeba7ec00be2defb106c9b9eec75f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Tue, 1 Sep 2026 10:21:57 +0200 Subject: [PATCH] webapi: img.decode() Missing, so Next.js and React lazy images threw TypeError. No decoding happens, so it resolves once the element exists. --- src/browser/tests/element/html/image.html | 9 +++++++++ src/browser/webapi/element/html/Image.zig | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/browser/tests/element/html/image.html b/src/browser/tests/element/html/image.html index e9d918f05..fcb9455e4 100644 --- a/src/browser/tests/element/html/image.html +++ b/src/browser/tests/element/html/image.html @@ -170,3 +170,12 @@ testing.expectEqual(testing.BASE_URL + 'element/html/over%209000!?hello=world%20!', img.src); } + + diff --git a/src/browser/webapi/element/html/Image.zig b/src/browser/webapi/element/html/Image.zig index 205af94c9..c27453a56 100644 --- a/src/browser/webapi/element/html/Image.zig +++ b/src/browser/webapi/element/html/Image.zig @@ -82,6 +82,11 @@ pub fn getComplete(self: *const Image) bool { return self._complete; } +/// Nothing is decoded here, so the image is always ready to insert. +pub fn decode(_: *const Image, frame: *Frame) !js.Promise { + return frame.js.local.?.resolvePromise(js.Undefined{}); +} + /// The one funnel for "this element's src became current": parser-created /// images, `img.src = ...` and `setAttribute`/`removeAttribute("src")` all /// land here. @@ -147,6 +152,7 @@ pub const JsApi = struct { pub const naturalWidth = bridge.accessor(Image.getNaturalWidth, null, .{}); pub const naturalHeight = bridge.accessor(Image.getNaturalHeight, null, .{}); pub const complete = bridge.accessor(Image.getComplete, null, .{}); + pub const decode = bridge.function(Image.decode, .{}); }; pub const Build = struct {