mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
dom: implement document.createComment
This commit is contained in:
@@ -137,6 +137,10 @@ pub const Document = struct {
|
|||||||
return try parser.documentCreateCDATASection(self, data);
|
return try parser.documentCreateCDATASection(self, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _createComment(self: *parser.Document, data: []const u8) !*parser.Comment {
|
||||||
|
return try parser.documentCreateComment(self, data);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -244,6 +248,11 @@ pub fn testExecFn(
|
|||||||
};
|
};
|
||||||
try checkCases(js_env, &createCDATASection);
|
try checkCases(js_env, &createCDATASection);
|
||||||
|
|
||||||
|
var createComment = [_]Case{
|
||||||
|
.{ .src = "document.createComment('foo')", .ex = "[object Comment]" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &createComment);
|
||||||
|
|
||||||
const tags = comptime parser.Tag.all();
|
const tags = comptime parser.Tag.all();
|
||||||
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
||||||
inline for (tags, 0..) |tag, i| {
|
inline for (tags, 0..) |tag, i| {
|
||||||
|
|||||||
@@ -1154,6 +1154,13 @@ pub inline fn documentCreateCDATASection(doc: *Document, s: []const u8) !*CDATAS
|
|||||||
return cdata.?;
|
return cdata.?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn documentCreateComment(doc: *Document, s: []const u8) !*Comment {
|
||||||
|
var com: ?*Comment = undefined;
|
||||||
|
const err = documentVtable(doc).dom_document_create_comment.?(doc, try strFromData(s), &com);
|
||||||
|
try DOMErr(err);
|
||||||
|
return com.?;
|
||||||
|
}
|
||||||
|
|
||||||
// DocumentHTML
|
// DocumentHTML
|
||||||
pub const DocumentHTML = c.dom_html_document;
|
pub const DocumentHTML = c.dom_html_document;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user