new Comment(?[]const u8)

This commit is contained in:
Karl Seguin
2025-12-11 07:41:08 +08:00
parent a355d9e517
commit 86ae004825
2 changed files with 15 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<!DOCTYPE html>
<script src="../testing.js"></script>
<script id=comment>
testing.expectEqual('', new Comment().data);
testing.expectEqual('over 9000! ', new Comment('over 9000! ').data);
</script>

View File

@@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const js = @import("../../js/js.zig");
const Page = @import("../../Page.zig");
const CData = @import("../CData.zig");
@@ -24,6 +25,11 @@ const Comment = @This();
_proto: *CData,
pub fn init(content: ?[]const u8, page: *Page) !*Comment {
const node = try page.createComment(content orelse "");
return node.as(Comment);
}
pub const JsApi = struct {
pub const bridge = js.Bridge(Comment);
@@ -32,4 +38,6 @@ pub const JsApi = struct {
pub const prototype_chain = bridge.prototypeChain();
pub var class_id: bridge.ClassId = undefined;
};
pub const constructor = bridge.constructor(Comment.init, .{});
};