mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-09-15 07:19:20 -04:00
webapi: img.decode()
Missing, so Next.js <Image> and React lazy images threw TypeError. No decoding happens, so it resolves once the element exists.
This commit is contained in:
1 parent
a43db3cbd2
commit
db64ced3fb
2 files changed
+15
No files matched your search
@@ -170,3 +170,12 @@
|
||||
testing.expectEqual(testing.BASE_URL + 'element/html/over%209000!?hello=world%20!', img.src);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="decode" type=module>
|
||||
const img = new Image();
|
||||
const p = img.decode();
|
||||
testing.expectEqual(true, p instanceof Promise);
|
||||
testing.expectEqual(undefined, await p);
|
||||
img.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACw=';
|
||||
testing.expectEqual(undefined, await img.decode());
|
||||
</script>
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user