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