mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
dom: implement document.createAttribute
This commit is contained in:
@@ -153,6 +153,10 @@ pub const Document = struct {
|
||||
return try parser.documentAdoptNode(self, node);
|
||||
}
|
||||
|
||||
pub fn _createAttribute(self: *parser.Document, name: []const u8) !*parser.Attribute {
|
||||
return try parser.documentCreateAttribute(self, name);
|
||||
}
|
||||
|
||||
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
|
||||
};
|
||||
|
||||
@@ -283,6 +287,11 @@ pub fn testExecFn(
|
||||
};
|
||||
try checkCases(js_env, &adoptNode);
|
||||
|
||||
var createAttr = [_]Case{
|
||||
.{ .src = "document.createAttribute('foo')", .ex = "[object Attr]" },
|
||||
};
|
||||
try checkCases(js_env, &createAttr);
|
||||
|
||||
const tags = comptime parser.Tag.all();
|
||||
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
||||
inline for (tags, 0..) |tag, i| {
|
||||
|
||||
@@ -1192,6 +1192,13 @@ pub inline fn documentAdoptNode(doc: *Document, node: *Node) !*Node {
|
||||
return @as(*Node, @ptrCast(res));
|
||||
}
|
||||
|
||||
pub inline fn documentCreateAttribute(doc: *Document, name: []const u8) !*Attribute {
|
||||
var attr: ?*Attribute = undefined;
|
||||
const err = documentVtable(doc).dom_document_create_attribute.?(doc, try strFromData(name), &attr);
|
||||
try DOMErr(err);
|
||||
return attr.?;
|
||||
}
|
||||
|
||||
// DocumentHTML
|
||||
pub const DocumentHTML = c.dom_html_document;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user