Skip to content

Lightpanda: the headless browser designed for AI and automation

perf: Skip CSSStyleProperty creation if there is no style attribute

Karl Seguin96e23f78e815
diff --git a/src/browser/StyleManager.zig b/src/browser/StyleManager.zig
index 79936e1d3..92d3a32e7 100644
--- a/src/browser/StyleManager.zig
+++ b/src/browser/StyleManager.zig
@@ -864,6 +864,10 @@ const CheckVisibilityOptions = struct {
const INLINE_PRIORITY: u64 = std.math.maxInt(u64);
fn getInlineStyleProperty(el: *Element, property_name: String, frame: *Frame) ?*CSSStyleProperty {
+ if (!el.hasAttributeSafe(comptime .wrap("style"))) {
+ // cheap guard to avoid creating the CSSStyleProperty if there is no style attribute
+ return null;
+ }
const style = el.getOrCreateStyle(frame) catch |err| {
log.err(.browser, "StyleManager getOrCreateStyle", .{ .err = err });
return null;