diff --git a/compiler/generate/visitors/attributes/addComponentAttributes.js b/compiler/generate/visitors/attributes/addComponentAttributes.js index 9f002cd6c4..9995352dc8 100644 --- a/compiler/generate/visitors/attributes/addComponentAttributes.js +++ b/compiler/generate/visitors/attributes/addComponentAttributes.js @@ -16,6 +16,13 @@ export default function addComponentAttributes ( generator, node, local ) { }); } + else if ( attribute.value.length === 0 ) { + local.staticAttributes.push({ + name: attribute.name, + value: `''` + }); + } + else if ( attribute.value.length === 1 ) { const value = attribute.value[0]; diff --git a/compiler/generate/visitors/attributes/addElementAttributes.js b/compiler/generate/visitors/attributes/addElementAttributes.js index b7aa5c4056..cb81a9a1f6 100644 --- a/compiler/generate/visitors/attributes/addElementAttributes.js +++ b/compiler/generate/visitors/attributes/addElementAttributes.js @@ -31,6 +31,18 @@ export default function addElementAttributes ( generator, node, local ) { } } + else if ( attribute.value.length === 0 ) { + if ( propertyName ) { + local.init.push( deindent` + ${local.name}.${propertyName} = ''; + ` ); + } else { + local.init.push( deindent` + ${local.name}.setAttribute( '${attribute.name}', '' ); + ` ); + } + } + else if ( attribute.value.length === 1 ) { const value = attribute.value[0]; diff --git a/test/compiler/attribute-empty/_config.js b/test/compiler/attribute-empty/_config.js new file mode 100644 index 0000000000..b9ce14cce1 --- /dev/null +++ b/test/compiler/attribute-empty/_config.js @@ -0,0 +1,3 @@ +export default { + html: `
` +}; diff --git a/test/compiler/attribute-empty/main.html b/test/compiler/attribute-empty/main.html new file mode 100644 index 0000000000..7c7b3d103a --- /dev/null +++ b/test/compiler/attribute-empty/main.html @@ -0,0 +1 @@ +
diff --git a/test/compiler/component-data-empty/Widget.html b/test/compiler/component-data-empty/Widget.html new file mode 100644 index 0000000000..89d0010a35 --- /dev/null +++ b/test/compiler/component-data-empty/Widget.html @@ -0,0 +1 @@ +

foo: '{{foo}}'

diff --git a/test/compiler/component-data-empty/_config.js b/test/compiler/component-data-empty/_config.js new file mode 100644 index 0000000000..eaf16a72af --- /dev/null +++ b/test/compiler/component-data-empty/_config.js @@ -0,0 +1,3 @@ +export default { + html: `

foo: ''

` +}; diff --git a/test/compiler/component-data-empty/main.html b/test/compiler/component-data-empty/main.html new file mode 100644 index 0000000000..8b797c8a60 --- /dev/null +++ b/test/compiler/component-data-empty/main.html @@ -0,0 +1,11 @@ +
+ +
+ +