mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-14 15:28:57 +00:00
new Comment(?[]const u8)
This commit is contained in:
7
src/browser/tests/cdata/comment.html
Normal file
7
src/browser/tests/cdata/comment.html
Normal 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>
|
||||
@@ -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, .{});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user