Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] textContent should not be set for <template> element. #7297

Merged
merged 4 commits into from Apr 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/compiler/compile/render_dom/wrappers/Element/index.ts
Expand Up @@ -289,7 +289,10 @@ export default class ElementWrapper extends Wrapper {

// insert static children with textContent or innerHTML
const can_use_textcontent = this.can_use_textcontent();
lidlanca marked this conversation as resolved.
Show resolved Hide resolved
if (!this.node.namespace && (this.can_use_innerhtml || can_use_textcontent) && this.fragment.nodes.length > 0) {
const isTemplate = this.node.name == 'template';
// skip textcontent logic for <template>. should append to the template .content
const isTemplateWithTextContent = isTemplate && can_use_textcontent;
if (!isTemplateWithTextContent && !this.node.namespace && (this.can_use_innerhtml || can_use_textcontent) && this.fragment.nodes.length > 0) {
if (this.fragment.nodes.length === 1 && this.fragment.nodes[0].node.type === 'Text') {
block.chunks.create.push(
b`${node}.textContent = ${string_literal((this.fragment.nodes[0] as TextWrapper).data)};`
Expand Down