diff --git a/src/browser/js/bridge.zig b/src/browser/js/bridge.zig index eccc7dc9..4319df25 100644 --- a/src/browser/js/bridge.zig +++ b/src/browser/js/bridge.zig @@ -563,4 +563,5 @@ pub const JsApis = flattenTypes(&.{ @import("../webapi/MutationObserver.zig"), @import("../webapi/IntersectionObserver.zig"), @import("../webapi/CustomElementRegistry.zig"), + @import("../webapi/ResizeObserver.zig"), }); diff --git a/src/browser/tests/url.html b/src/browser/tests/url.html index 145d368e..7faefc32 100644 --- a/src/browser/tests/url.html +++ b/src/browser/tests/url.html @@ -314,3 +314,51 @@ testing.expectEqual('https://example.com/path', url.href); } + + diff --git a/src/browser/webapi/ResizeObserver.zig b/src/browser/webapi/ResizeObserver.zig new file mode 100644 index 00000000..544db3ee --- /dev/null +++ b/src/browser/webapi/ResizeObserver.zig @@ -0,0 +1,64 @@ +// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// +// Francis Bouvier +// Pierre Tachoire +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +const std = @import("std"); +const js = @import("../js/js.zig"); +const Page = @import("../Page.zig"); +const Element = @import("Element.zig"); + +pub const ResizeObserver = @This(); + +fn init(cbk: js.Function) ResizeObserver { + _ = cbk; + return .{}; +} + +const Options = struct { + box: []const u8, +}; +pub fn observe(self: *const ResizeObserver, element: *Element, options_: ?Options) void { + _ = self; + _ = element; + _ = options_; + return; +} + +pub fn unobserve(self: *const ResizeObserver, element: *Element) void { + _ = self; + _ = element; + return; +} + +pub fn disconnect(self: *ResizeObserver) void { + _ = self; +} + +pub const JsApi = struct { + pub const bridge = js.Bridge(ResizeObserver); + + pub const Meta = struct { + pub const name = "ResizeObserver"; + pub const prototype_chain = bridge.prototypeChain(); + pub var class_id: bridge.ClassId = undefined; + pub const empty_with_no_proto = true; + }; + + pub const constructor = bridge.constructor(ResizeObserver.init, .{}); + pub const observe = bridge.function(ResizeObserver.observe, .{}); + pub const disconnect = bridge.function(ResizeObserver.disconnect, .{}); +}; diff --git a/src/browser/webapi/element/html/Anchor.zig b/src/browser/webapi/element/html/Anchor.zig index 8821ec61..47cbe9d4 100644 --- a/src/browser/webapi/element/html/Anchor.zig +++ b/src/browser/webapi/element/html/Anchor.zig @@ -243,6 +243,7 @@ pub const JsApi = struct { pub const hash = bridge.accessor(Anchor.getHash, Anchor.setHash, .{}); pub const @"type" = bridge.accessor(Anchor.getType, Anchor.setType, .{}); pub const text = bridge.accessor(Anchor.getText, Anchor.setText, .{}); + pub const toString = bridge.function(Anchor.getHref, .{}); }; const testing = @import("../../../../testing.zig");