File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -60,14 +60,24 @@ pub const Element = struct {
6060
6161 pub fn toInterfaceT (comptime T : type , e : * parser.Element ) ! T {
6262 const tagname = try parser .elementGetTagName (e ) orelse {
63- // in case of null tagname, return the element as it.
63+ // If the owner's document is HTML, assume we have an HTMLElement.
64+ const doc = try parser .nodeOwnerDocument (parser .elementToNode (e ));
65+ if (doc != null and ! doc .? .is_html ) {
66+ return .{ .HTMLElement = @as (* parser .ElementHTML , @ptrCast (e )) };
67+ }
68+
6469 return .{ .Element = e };
6570 };
6671
6772 // TODO SVGElement and MathML are not supported yet.
6873
6974 const tag = parser .Tag .fromString (tagname ) catch {
70- // if the tag is invalid, we don't have an HTMLElement.
75+ // If the owner's document is HTML, assume we have an HTMLElement.
76+ const doc = try parser .nodeOwnerDocument (parser .elementToNode (e ));
77+ if (doc != null and doc .? .is_html ) {
78+ return .{ .HTMLElement = @as (* parser .ElementHTML , @ptrCast (e )) };
79+ }
80+
7181 return .{ .Element = e };
7282 };
7383
Original file line number Diff line number Diff line change @@ -61,5 +61,7 @@ test "Browser.webcomponents" {
6161 },
6262
6363 .{ "main.innerHTML" , "<lightpanda-test>connected</lightpanda-test>" },
64+ .{ "document.createElement('lightpanda-test').dataset" , "[object DataSet]" },
65+ .{ "document.createElement('lightpanda-test.x').dataset" , "[object DataSet]" },
6466 }, .{});
6567}
You can’t perform that action at this time.
0 commit comments