pull/1815/head
Rich Harris 6 years ago
parent a704cb77de
commit b21f1d8859

@ -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;
}
}

@ -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)}"`;
}
});
}

Loading…
Cancel
Save