From 24a338a4e8c643350ac68269def95e3413d13244 Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Sun, 31 Oct 2021 18:54:07 +0900 Subject: [PATCH] refactor render_ssr --- .../render_ssr/handlers/DynamicElement.ts | 6 +++-- .../compile/render_ssr/handlers/Element.ts | 24 +++---------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/compiler/compile/render_ssr/handlers/DynamicElement.ts b/src/compiler/compile/render_ssr/handlers/DynamicElement.ts index b3d7df518a..96cc23432d 100644 --- a/src/compiler/compile/render_ssr/handlers/DynamicElement.ts +++ b/src/compiler/compile/render_ssr/handlers/DynamicElement.ts @@ -20,8 +20,10 @@ export default function (node: Element, renderer: Renderer, options: RenderOptio // awkward special case let node_contents; - const contenteditable = node.attributes.some( - (attribute) => attribute.name === 'contenteditable' + const contenteditable = ( + node.name !== 'textarea' && + node.name !== 'input' && + node.attributes.some((attribute) => attribute.name === 'contenteditable') ); const slot = node.get_static_attribute_value('slot'); diff --git a/src/compiler/compile/render_ssr/handlers/Element.ts b/src/compiler/compile/render_ssr/handlers/Element.ts index 8d84ea0bc0..c0bf826a8e 100644 --- a/src/compiler/compile/render_ssr/handlers/Element.ts +++ b/src/compiler/compile/render_ssr/handlers/Element.ts @@ -6,7 +6,6 @@ import Element from '../../nodes/Element'; import { x } from 'code-red'; import Expression from '../../nodes/shared/Expression'; import remove_whitespace_children from './utils/remove_whitespace_children'; -import { Expression as ESExpression } from 'estree'; import fix_attribute_casing from '../../render_dom/wrappers/Element/fix_attribute_casing'; import { namespaces } from '../../../utils/namespaces'; @@ -23,12 +22,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption node.attributes.some((attribute) => attribute.name === 'contenteditable') ); - if (node.type === 'DynamicElement') { - renderer.add_string('<'); - renderer.add_expression(node.dynamic_tag_expr.node as ESExpression); - } else { - renderer.add_string(`<${node.name}`); - } + renderer.add_string(`<${node.name}`); const class_expression_list = node.classes.map(class_directive => { const { expression, name } = class_directive; @@ -158,25 +152,13 @@ export default function(node: Element, renderer: Renderer, options: RenderOption } if (!is_void(node.name)) { - if (node.type === 'DynamicElement') { - renderer.add_string(''); - } else { - renderer.add_string(``); - } + renderer.add_string(``); } } else { renderer.render(children, options); if (!is_void(node.name)) { - if (node.type === 'DynamicElement') { - renderer.add_string(''); - } else { - renderer.add_string(``); - } + renderer.add_string(``); } } }