From 25a12a76efa1e08de69f7869728534d6ee5dcc9e Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Sat, 6 Nov 2021 13:53:00 +0900 Subject: [PATCH] refactor --- src/compiler/compile/nodes/Element.ts | 17 ++++++++--------- .../render_dom/wrappers/Element/index.ts | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index a7fdd12e1f..71e4dc1792 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -143,17 +143,16 @@ export default class Element extends Node { constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode) { super(component, parent, scope, info); - this.name = info.name; + if (info.name === 'svelte:element' && typeof info.tag === 'string') { + this.name = info.tag; + } else { + this.name = info.name; + } - if (info.name === 'svelte:element') { - if (typeof info.tag === 'string') { - this.name = info.tag; - this.tag_expr = new Expression(component, this, scope, string_literal(info.tag) as Literal); - } else { - this.tag_expr = new Expression(component, this, scope, info.tag); - } + if (info.name === 'svelte:element' && typeof info.tag !== 'string') { + this.tag_expr = new Expression(component, this, scope, info.tag); } else { - this.tag_expr = new Expression(component, this, scope, string_literal(info.name) as Literal); + this.tag_expr = new Expression(component, this, scope, string_literal(this.name) as Literal); } this.namespace = get_namespace(parent as Element, this, component.namespace); diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index 5a86180a55..a5bb7790a1 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -221,7 +221,7 @@ export default class ElementWrapper extends Wrapper { node.intro || node.outro || node.handlers.length > 0 || this.node.name === 'option' || - node.is_dynamic_element || + node.tag_expr.dynamic_dependencies().length || renderer.options.dev ) { this.parent.cannot_use_innerhtml(); // need to use add_location