mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
dom: implement document.createTextNode
This commit is contained in:
@@ -129,6 +129,10 @@ pub const Document = struct {
|
|||||||
return try parser.documentCreateDocumentFragment(self);
|
return try parser.documentCreateDocumentFragment(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _createTextNode(self: *parser.Document, data: []const u8) !*parser.Text {
|
||||||
|
return try parser.documentCreateTextNode(self, data);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -226,6 +230,11 @@ pub fn testExecFn(
|
|||||||
};
|
};
|
||||||
try checkCases(js_env, &createDocumentFragment);
|
try checkCases(js_env, &createDocumentFragment);
|
||||||
|
|
||||||
|
var createTextNode = [_]Case{
|
||||||
|
.{ .src = "document.createTextNode('foo')", .ex = "[object Text]" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &createTextNode);
|
||||||
|
|
||||||
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| {
|
||||||
|
|||||||
@@ -1137,6 +1137,13 @@ pub inline fn documentCreateDocumentFragment(doc: *Document) !*DocumentFragment
|
|||||||
return df.?;
|
return df.?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn documentCreateTextNode(doc: *Document, s: []const u8) !*Text {
|
||||||
|
var txt: ?*Text = undefined;
|
||||||
|
const err = documentVtable(doc).dom_document_create_text_node.?(doc, try strFromData(s), &txt);
|
||||||
|
try DOMErr(err);
|
||||||
|
return txt.?;
|
||||||
|
}
|
||||||
|
|
||||||
// DocumentHTML
|
// DocumentHTML
|
||||||
pub const DocumentHTML = c.dom_html_document;
|
pub const DocumentHTML = c.dom_html_document;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user