mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 15:58:57 +00:00
dummy ResizeObserver
This commit is contained in:
@@ -563,4 +563,5 @@ pub const JsApis = flattenTypes(&.{
|
||||
@import("../webapi/MutationObserver.zig"),
|
||||
@import("../webapi/IntersectionObserver.zig"),
|
||||
@import("../webapi/CustomElementRegistry.zig"),
|
||||
@import("../webapi/ResizeObserver.zig"),
|
||||
});
|
||||
|
||||
@@ -314,3 +314,51 @@
|
||||
testing.expectEqual('https://example.com/path', url.href);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id=stringifier>
|
||||
{
|
||||
const url1 = new URL('https://example.com/api');
|
||||
const url2 = new URL(url1);
|
||||
testing.expectEqual('https://example.com/api', url2.href);
|
||||
}
|
||||
|
||||
{
|
||||
const obj = {
|
||||
toString() {
|
||||
return 'https://example.com/custom';
|
||||
}
|
||||
};
|
||||
const url = new URL(obj);
|
||||
testing.expectEqual('https://example.com/custom', url.href);
|
||||
}
|
||||
|
||||
{
|
||||
const baseUrl = new URL('https://example.com/');
|
||||
const url = new URL('/path', baseUrl);
|
||||
testing.expectEqual('https://example.com/path', url.href);
|
||||
}
|
||||
|
||||
{
|
||||
const obj = {
|
||||
toString() {
|
||||
return 'https://example.com/';
|
||||
}
|
||||
};
|
||||
const url = new URL('/relative', obj);
|
||||
testing.expectEqual('https://example.com/relative', url.href);
|
||||
}
|
||||
|
||||
{
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = 'https://example.com/test';
|
||||
const url = new URL(anchor);
|
||||
testing.expectEqual('https://example.com/test', url.href);
|
||||
}
|
||||
|
||||
{
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = 'https://example.com/base/';
|
||||
const url = new URL('relative', anchor);
|
||||
testing.expectEqual('https://example.com/base/relative', url.href);
|
||||
}
|
||||
</script>
|
||||
|
||||
64
src/browser/webapi/ResizeObserver.zig
Normal file
64
src/browser/webapi/ResizeObserver.zig
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2023-2025 Lightpanda (Selecy SAS)
|
||||
//
|
||||
// Francis Bouvier <francis@lightpanda.io>
|
||||
// Pierre Tachoire <pierre@lightpanda.io>
|
||||
//
|
||||
// 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
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, .{});
|
||||
};
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user