add selectionchange handler on Document

This commit is contained in:
Muki Kiboigo
2026-02-09 06:27:34 -08:00
parent 2e5d04389b
commit 5e32ccbf12

View File

@@ -56,6 +56,20 @@ _script_created_parser: ?Parser.Streaming = null,
_adopted_style_sheets: ?js.Object.Global = null,
_selection: Selection = .init,
_on_selectionchange: ?js.Function.Global = null,
pub fn getOnSelectionChange(self: *Document) ?js.Function.Global {
return self._on_selectionchange;
}
pub fn setOnSelectionChange(self: *Document, listener: ?js.Function) !void {
if (listener) |listen| {
self._on_selectionchange = try listen.persistWithThis(self);
} else {
self._on_selectionchange = null;
}
}
pub const Type = union(enum) {
generic,
html: *HTMLDocument,
@@ -930,6 +944,7 @@ pub const JsApi = struct {
});
}
pub const onselectionchange = bridge.accessor(Document.getOnSelectionChange, Document.setOnSelectionChange, .{});
pub const URL = bridge.accessor(Document.getURL, null, .{});
pub const documentURI = bridge.accessor(Document.getURL, null, .{});
pub const documentElement = bridge.accessor(Document.getDocumentElement, null, .{});