mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
add Option.text setter
This commit is contained in:
@@ -29,6 +29,12 @@
|
|||||||
testing.expectEqual('Text 3', $('#opt3').text)
|
testing.expectEqual('Text 3', $('#opt3').text)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script id="text_set">
|
||||||
|
$('#opt1').text = 'New Text 1'
|
||||||
|
testing.expectEqual('New Text 1', $('#opt1').text)
|
||||||
|
testing.expectEqual('New Text 1', $('#opt1').textContent)
|
||||||
|
</script>
|
||||||
|
|
||||||
<script id="selected">
|
<script id="selected">
|
||||||
testing.expectEqual(false, $('#opt1').selected)
|
testing.expectEqual(false, $('#opt1').selected)
|
||||||
testing.expectEqual(true, $('#opt2').selected)
|
testing.expectEqual(true, $('#opt2').selected)
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ pub fn getText(self: *const Option) []const u8 {
|
|||||||
return node.getTextContentAlloc(allocator) catch "";
|
return node.getTextContentAlloc(allocator) catch "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setText(self: *Option, value: []const u8, page: *Page) !void {
|
||||||
|
try self.asNode().setTextContent(value, page);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn getSelected(self: *const Option) bool {
|
pub fn getSelected(self: *const Option) bool {
|
||||||
return self._selected;
|
return self._selected;
|
||||||
}
|
}
|
||||||
@@ -113,7 +117,7 @@ pub const JsApi = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub const value = bridge.accessor(Option.getValue, Option.setValue, .{});
|
pub const value = bridge.accessor(Option.getValue, Option.setValue, .{});
|
||||||
pub const text = bridge.accessor(Option.getText, null, .{});
|
pub const text = bridge.accessor(Option.getText, Option.setText, .{});
|
||||||
pub const selected = bridge.accessor(Option.getSelected, Option.setSelected, .{});
|
pub const selected = bridge.accessor(Option.getSelected, Option.setSelected, .{});
|
||||||
pub const defaultSelected = bridge.accessor(Option.getDefaultSelected, null, .{});
|
pub const defaultSelected = bridge.accessor(Option.getDefaultSelected, null, .{});
|
||||||
pub const disabled = bridge.accessor(Option.getDisabled, Option.setDisabled, .{});
|
pub const disabled = bridge.accessor(Option.getDisabled, Option.setDisabled, .{});
|
||||||
|
|||||||
Reference in New Issue
Block a user