don't hash @html because it's not guranteed that input is the same on the server and client

pull/7426/head
Simon Holthausen 3 years ago
parent f891995017
commit 0f137aca77

@ -4,6 +4,7 @@ export default class RawMustacheTag extends Tag {
type: 'RawMustacheTag'; type: 'RawMustacheTag';
constructor(component, parent, scope, info) { constructor(component, parent, scope, info) {
super(component, parent, scope, info); super(component, parent, scope, info);
this.cannot_use_innerhtml();
this.not_static_content(); this.not_static_content();
} }
} }

@ -36,7 +36,7 @@ export default class RawMustacheTagWrapper extends Tag {
content => insert(content) 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 { } else {
const needs_anchor = in_head || (this.next ? !this.next.is_dom_node() : (!this.parent || !this.parent.is_dom_node())); const needs_anchor = in_head || (this.next ? !this.next.is_dom_node() : (!this.parent || !this.parent.is_dom_node()));

@ -49,7 +49,6 @@ export interface RenderOptions extends CompileOptions{
locate: (c: number) => { line: number; column: number }; locate: (c: number) => { line: number; column: number };
head_id?: string; head_id?: string;
has_added_svelte_hash?: boolean; has_added_svelte_hash?: boolean;
optimised_html_hydration?: boolean;
} }
export default class Renderer { export default class Renderer {

@ -160,10 +160,7 @@ export default function (node: Element, renderer: Renderer, options: RenderOptio
}); });
if (options.hydratable) { if (options.hydratable) {
if (node.children.length === 1 && node.children[0].type === 'RawMustacheTag') { if (node.can_optimise_to_html_string && !options.has_added_svelte_hash) {
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) {
renderer.add_string(` data-svelte-h="${node.hash()}"`); renderer.add_string(` data-svelte-h="${node.hash()}"`);
options = { ...options, has_added_svelte_hash: true }; options = { ...options, has_added_svelte_hash: true };
} }

@ -3,7 +3,7 @@ import RawMustacheTag from '../../nodes/RawMustacheTag';
import { Expression } from 'estree'; import { Expression } from 'estree';
export default function(node: RawMustacheTag, renderer: Renderer, options: RenderOptions) { export default function(node: RawMustacheTag, renderer: Renderer, options: RenderOptions) {
if (options.hydratable && !options.optimised_html_hydration) renderer.add_string('<!-- HTML_TAG_START -->'); if (options.hydratable) renderer.add_string('<!-- HTML_TAG_START -->');
renderer.add_expression(node.expression.node as Expression); renderer.add_expression(node.expression.node as Expression);
if (options.hydratable && !options.optimised_html_hydration) renderer.add_string('<!-- HTML_TAG_END -->'); if (options.hydratable) renderer.add_string('<!-- HTML_TAG_END -->');
} }

Loading…
Cancel
Save