mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
spread new stringToPersistedFunction
This commit is contained in:
@@ -387,22 +387,17 @@ pub fn getAttributeFunction(
|
||||
}
|
||||
|
||||
const attr = element.getAttributeSafe(.wrap(@tagName(listener_type))) orelse return null;
|
||||
const callback = page.js.stringToPersistedFunction(attr) catch |err| switch (err) {
|
||||
error.OutOfMemory => return err,
|
||||
else => {
|
||||
// Not a valid expression; log this to find out if its something we should be supporting.
|
||||
log.warn(.js, "Html.getAttributeFunction", .{
|
||||
.expression = attr,
|
||||
.err = err,
|
||||
});
|
||||
|
||||
return null;
|
||||
},
|
||||
const function = page.js.stringToPersistedFunction(attr, &.{"event"}, &.{}) catch |err| {
|
||||
// Not a valid expression; log this to find out if its something we should be supporting.
|
||||
log.warn(.js, "Html.getAttributeFunction", .{
|
||||
.expression = attr,
|
||||
.err = err,
|
||||
});
|
||||
return null;
|
||||
};
|
||||
|
||||
try self.setAttributeListener(listener_type, callback, page);
|
||||
|
||||
return callback;
|
||||
try self.setAttributeListener(listener_type, function, page);
|
||||
return function;
|
||||
}
|
||||
|
||||
pub fn hasAttributeFunction(self: *HtmlElement, listener_type: GlobalEventHandler, page: *const Page) bool {
|
||||
|
||||
@@ -50,7 +50,7 @@ pub const Build = struct {
|
||||
pub fn complete(node: *Node, page: *Page) !void {
|
||||
const el = node.as(Element);
|
||||
const on_load = el.getAttributeSafe(comptime .wrap("onload")) orelse return;
|
||||
if (page.js.stringToPersistedFunction(on_load)) |func| {
|
||||
if (page.js.stringToPersistedFunction(on_load, &.{"event"}, &.{})) |func| {
|
||||
page.window._on_load = func;
|
||||
} else |err| {
|
||||
log.err(.js, "body.onload", .{ .err = err, .str = on_load });
|
||||
|
||||
Reference in New Issue
Block a user