Skip to content

HTMLTemplateElement does not parse content #1172

@carson-katri

Description

@carson-katri

When parsing with DOMParser in JS, any HTMLTemplateElement discards its content.

<template>hello, world</template>

After parsing, when calling get_content on this element a fresh DocumentFragment is created instead of returning the DocumentFragment with the hello, world text node.

pub fn get_content(self: *parser.Template, page: *Page) !*parser.DocumentFragment {
const state = try page.getOrCreateNodeState(@ptrCast(@alignCast(self)));
if (state.template_content) |tc| {
return tc;
}
const tc = try parser.documentCreateDocumentFragment(@ptrCast(page.window.document));
state.template_content = tc;
return tc;
}

I'm not sure if the parser needs to setup the node state, or get_content needs to be adjusted to pull the content from the correct place.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions