backport some node_lexbor modifications

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-09-21 17:05:38 +02:00
parent 4708dbd679
commit b5b4659c87
5 changed files with 166 additions and 79 deletions

View File

@@ -12,7 +12,7 @@ pub const HTMLElement = struct {
pub const mem_guarantied = true;
};
pub const HTMLElementsTypes = .{
pub const Types = .{
HTMLUnknownElement,
HTMLAnchorElement,
HTMLAreaElement,
@@ -74,9 +74,9 @@ pub const HTMLElementsTypes = .{
HTMLUListElement,
HTMLVideoElement,
};
const HTMLElementsGenerated = generate.Union.compile(HTMLElementsTypes);
pub const HTMLElements = HTMLElementsGenerated._union;
pub const HTMLElementsTags = HTMLElementsGenerated._enum;
const Generated = generate.Union.compile(Types);
pub const Union = Generated._union;
pub const Tags = Generated._enum;
// Deprecated HTMLElements in Chrome (2023/03/15)
// HTMLContentelement
@@ -454,7 +454,7 @@ pub const HTMLVideoElement = struct {
pub const mem_guarantied = true;
};
pub fn ElementToHTMLElementInterface(elem: *parser.Element) HTMLElements {
pub fn toInterface(comptime T: type, elem: *parser.Element) T {
const tag = parser.elementHTMLGetTagType(@as(*parser.ElementHTML, @ptrCast(elem)));
return switch (tag) {
.a => .{ .HTMLAnchorElement = @as(*parser.Anchor, @ptrCast(elem)) },