From 0f137aca77defdd37fefbd4da697459df223919b Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Mon, 3 Apr 2023 11:59:00 +0200 Subject: [PATCH] don't hash @html because it's not guranteed that input is the same on the server and client --- src/compiler/compile/nodes/RawMustacheTag.ts | 1 + src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts | 2 +- src/compiler/compile/render_ssr/Renderer.ts | 1 - src/compiler/compile/render_ssr/handlers/Element.ts | 5 +---- src/compiler/compile/render_ssr/handlers/HtmlTag.ts | 4 ++-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/compiler/compile/nodes/RawMustacheTag.ts b/src/compiler/compile/nodes/RawMustacheTag.ts index 998fdce3ad..99aeba2623 100644 --- a/src/compiler/compile/nodes/RawMustacheTag.ts +++ b/src/compiler/compile/nodes/RawMustacheTag.ts @@ -4,6 +4,7 @@ export default class RawMustacheTag extends Tag { type: 'RawMustacheTag'; constructor(component, parent, scope, info) { super(component, parent, scope, info); + this.cannot_use_innerhtml(); this.not_static_content(); } } diff --git a/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts b/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts index d3c502a9c6..acecb2e076 100644 --- a/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts +++ b/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts @@ -36,7 +36,7 @@ export default class RawMustacheTagWrapper extends Tag { content => insert(content) ); - block.chunks.mount.push(b`if (@get_svelte_dataset(${parent_node}) !== "${hash(JSON.stringify(this.node.expression.node))}") ${insert(init)}`); + block.chunks.mount.push(insert(init)); } else { const needs_anchor = in_head || (this.next ? !this.next.is_dom_node() : (!this.parent || !this.parent.is_dom_node())); diff --git a/src/compiler/compile/render_ssr/Renderer.ts b/src/compiler/compile/render_ssr/Renderer.ts index b40e5cb4bd..5fd473a9cf 100644 --- a/src/compiler/compile/render_ssr/Renderer.ts +++ b/src/compiler/compile/render_ssr/Renderer.ts @@ -49,7 +49,6 @@ export interface RenderOptions extends CompileOptions{ locate: (c: number) => { line: number; column: number }; head_id?: string; has_added_svelte_hash?: boolean; - optimised_html_hydration?: boolean; } export default class Renderer { diff --git a/src/compiler/compile/render_ssr/handlers/Element.ts b/src/compiler/compile/render_ssr/handlers/Element.ts index 485f5e9ee3..4fe28cdb9f 100644 --- a/src/compiler/compile/render_ssr/handlers/Element.ts +++ b/src/compiler/compile/render_ssr/handlers/Element.ts @@ -160,10 +160,7 @@ export default function (node: Element, renderer: Renderer, options: RenderOptio }); if (options.hydratable) { - if (node.children.length === 1 && node.children[0].type === 'RawMustacheTag') { - renderer.add_string(` data-svelte-h="${hash(JSON.stringify(node.children[0].expression.node))}"`); - options = { ...options, optimised_html_hydration: true }; - } else if (node.can_optimise_to_html_string && !options.has_added_svelte_hash) { + if (node.can_optimise_to_html_string && !options.has_added_svelte_hash) { renderer.add_string(` data-svelte-h="${node.hash()}"`); options = { ...options, has_added_svelte_hash: true }; } diff --git a/src/compiler/compile/render_ssr/handlers/HtmlTag.ts b/src/compiler/compile/render_ssr/handlers/HtmlTag.ts index 89ec16df8c..cd62b95981 100644 --- a/src/compiler/compile/render_ssr/handlers/HtmlTag.ts +++ b/src/compiler/compile/render_ssr/handlers/HtmlTag.ts @@ -3,7 +3,7 @@ import RawMustacheTag from '../../nodes/RawMustacheTag'; import { Expression } from 'estree'; export default function(node: RawMustacheTag, renderer: Renderer, options: RenderOptions) { - if (options.hydratable && !options.optimised_html_hydration) renderer.add_string(''); + if (options.hydratable) renderer.add_string(''); renderer.add_expression(node.expression.node as Expression); - if (options.hydratable && !options.optimised_html_hydration) renderer.add_string(''); + if (options.hydratable) renderer.add_string(''); }