Skip to content

Commit b17f20e

Browse files
committed
make getComptedStyle return an empty CSSStyleDeclaration
1 parent eae9f9c commit b17f20e

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/browser/cssom/css_style_declaration.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ pub const CSSStyleDeclaration = struct {
3333
store: std.StringHashMapUnmanaged(Property),
3434
order: std.ArrayListUnmanaged([]const u8),
3535

36+
pub const empty: CSSStyleDeclaration = .{
37+
.store = .empty,
38+
.order = .empty,
39+
};
40+
3641
const Property = struct {
3742
value: []const u8,
3843
priority: bool,

src/browser/html/elements.zig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ pub const HTMLElement = struct {
109109
pub const prototype = *Element;
110110
pub const subtype = .node;
111111

112-
style: CSSStyleDeclaration = .{
113-
.store = .{},
114-
.order = .{},
115-
},
112+
style: CSSStyleDeclaration = .empty,
116113

117114
pub fn get_style(e: *parser.ElementHTML, state: *SessionState) !*CSSStyleDeclaration {
118115
const self = try state.getOrCreateNodeWrapper(HTMLElement, @ptrCast(e));

src/browser/html/window.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const Console = @import("../console/console.zig").Console;
3131
const EventTarget = @import("../dom/event_target.zig").EventTarget;
3232
const MediaQueryList = @import("media_query_list.zig").MediaQueryList;
3333
const Performance = @import("performance.zig").Performance;
34+
const CSSStyleDeclaration = @import("../cssom/css_style_declaration.zig").CSSStyleDeclaration;
3435

3536
const storage = @import("../storage/storage.zig");
3637

@@ -237,13 +238,13 @@ pub const Window = struct {
237238
return timer_id;
238239
}
239240

240-
// NOT IMPLEMENTED - This is a dummy implementation that always returns null to deter PlayWright from using this path to solve click.js.
241-
// returns an object containing the values of all CSS properties of an element, after applying active stylesheets and resolving any basic computation those values may contain.
242-
pub fn _getComputedStyle(_: *Window, element: *parser.Element, pseudo_element: ?[]const u8) !?void {
241+
// TODO: getComputedStyle should return a read-only CSSStyleDeclaration.
242+
// We currently don't have a read-only one, so we return a new instance on
243+
// each call.
244+
pub fn _getComputedStyle(_: *Window, element: *parser.Element, pseudo_element: ?[]const u8) !CSSStyleDeclaration {
243245
_ = element;
244246
_ = pseudo_element;
245-
log.warn("Not implemented function getComputedStyle called, null returned", .{});
246-
return null;
247+
return .empty;
247248
}
248249
};
249250

0 commit comments

Comments
 (0)