return template

pull/14269/head
Rich Harris 2 years ago
parent 0e543dea1e
commit c445309b10

@ -364,8 +364,7 @@ export function RegularElement(node, context) {
let { value } = build_template_literal(trimmed, context.visit, child_state); let { value } = build_template_literal(trimmed, context.visit, child_state);
// if the expression is inlinable we just push it to the template // if the expression is inlinable we just push it to the template
if (is_inlinable_expression(trimmed)) { if (is_inlinable_expression(trimmed)) {
escape_template_quasis(value); state.template.push(escape_template_quasis(value));
state.template.push(value);
} else { } else {
// else we programmatically set the value // else we programmatically set the value
child_state.init.push( child_state.init.push(
@ -598,8 +597,7 @@ function build_element_attribute_update_assignment(element, node_id, attribute,
return true; return true;
} else { } else {
if (inlinable_expression) { if (inlinable_expression) {
escape_template_quasis(value, true); context.state.template.push(` ${name}="`, escape_template_quasis(value, true), '"');
context.state.template.push(` ${name}="`, value, '"');
} else { } else {
state.init.push(update); state.init.push(update);
} }

@ -1,4 +1,4 @@
/** @import { Expression, ExpressionStatement, Identifier, MemberExpression, Statement, Super, TemplateLiteral, Literal } from 'estree' */ /** @import { Expression, ExpressionStatement, Identifier, MemberExpression, Statement, Super, TemplateLiteral, Node } from 'estree' */
/** @import { AST, SvelteNode } from '#compiler' */ /** @import { AST, SvelteNode } from '#compiler' */
/** @import { ComponentClientTransformState } from '../../types' */ /** @import { ComponentClientTransformState } from '../../types' */
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
@ -35,12 +35,12 @@ export function get_states_and_calls(values) {
/** /**
* Escape the html in every quasi in the template literal * Escape the html in every quasi in the template literal
* @param {SvelteNode} template * @param {Expression} template
* @param {boolean} [is_attr] * @param {boolean} [is_attr]
*/ */
export function escape_template_quasis(template, is_attr) { export function escape_template_quasis(template, is_attr) {
walk( walk(
template, /** @type {Node} */ (template),
{}, {},
{ {
TemplateLiteral(node, { next }) { TemplateLiteral(node, { next }) {
@ -59,6 +59,8 @@ export function escape_template_quasis(template, is_attr) {
} }
} }
); );
return template;
} }
/** /**

Loading…
Cancel
Save