From b21f1d8859ddcf29f04b107e5b783acf6598f280 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 27 Oct 2018 19:42:40 -0400 Subject: [PATCH] fixes --- src/compile/nodes/Attribute.ts | 4 ---- src/compile/render-ssr/handlers/Element.ts | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/compile/nodes/Attribute.ts b/src/compile/nodes/Attribute.ts index 6eb3393f40..0a85d6b850 100644 --- a/src/compile/nodes/Attribute.ts +++ b/src/compile/nodes/Attribute.ts @@ -16,7 +16,6 @@ export default class Attribute extends Node { name: string; isSpread: boolean; isTrue: boolean; - isConcatenated: boolean; isDynamic: boolean; isSynthetic: boolean; shouldCache: boolean; @@ -39,7 +38,6 @@ export default class Attribute extends Node { this.isDynamic = true; // TODO not necessarily this.shouldCache = false; // TODO does this mean anything here? - this.isConcatenated = false; } else { @@ -67,8 +65,6 @@ export default class Attribute extends Node { ? this.chunks[0].node.type !== 'Identifier' || scope.names.has(this.chunks[0].node.name) : true : false; - - this.isConcatenated = this.chunks.length > 1; } } diff --git a/src/compile/render-ssr/handlers/Element.ts b/src/compile/render-ssr/handlers/Element.ts index b9aaaa664e..d7bc823be2 100644 --- a/src/compile/render-ssr/handlers/Element.ts +++ b/src/compile/render-ssr/handlers/Element.ts @@ -109,13 +109,13 @@ export default function(node, renderer, options) { } else if (attribute.name === 'class' && classExpr) { addClassAttribute = false; openingTag += ` class="\${[\`${stringifyAttribute(attribute)}\`, ${classExpr}].join(' ').trim() }"`; - } else if (attribute.isConcatenated || !attribute.isDynamic) { - openingTag += ` ${attribute.name}="${stringifyAttribute(attribute)}"`; - } else { + } else if (attribute.chunks.length === 1 && attribute.chunks[0].type !== 'Text') { const { name } = attribute; const { snippet } = attribute.chunks[0]; - openingTag += '${(v => v == null ? "" : ` ' + name + '=${' + snippet + '}`)(' + snippet + ')}'; + openingTag += '${(v => v == null ? "" : ` ' + name + '="${@escape(' + snippet + ')}"`)(' + snippet + ')}'; + } else { + openingTag += ` ${attribute.name}="${stringifyAttribute(attribute)}"`; } }); }