mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
better handling of bare attribute names in DOM mode (#1852)
- compile unknown bare attribute names to setting the attribute to "" - correctly stringify as bare attribute name in .innerHTML'd markup
This commit is contained in:
parent
88b6a26a35
commit
e97953baec
@ -187,7 +187,7 @@ export default class AttributeWrapper {
|
||||
? `${element.var}.${propertyName} = ${value};`
|
||||
: isDataSet
|
||||
? `${element.var}.dataset.${camelCaseName} = ${value};`
|
||||
: `${method}(${element.var}, "${name}", ${value});`
|
||||
: `${method}(${element.var}, "${name}", ${value === true ? '""' : value});`
|
||||
);
|
||||
|
||||
block.builders.hydrate.addLine(statement);
|
||||
@ -207,9 +207,9 @@ export default class AttributeWrapper {
|
||||
}
|
||||
|
||||
stringify() {
|
||||
const value = this.node.chunks;
|
||||
if (this.node.isTrue) return '';
|
||||
|
||||
if (value === true) return '';
|
||||
const value = this.node.chunks;
|
||||
if (value.length === 0) return `=""`;
|
||||
|
||||
return `="${value.map(chunk => {
|
||||
|
Loading…
Reference in New Issue
Block a user