diff --git a/src/compile/nodes/Component.ts b/src/compile/nodes/Component.ts index 5fd91bf484..a782ca34db 100644 --- a/src/compile/nodes/Component.ts +++ b/src/compile/nodes/Component.ts @@ -155,7 +155,7 @@ export default class Component extends Node { componentInitProperties.push(`data: ${name_initial_data}`); } - if ((!usesSpread && this.attributes.filter(a => a.isDynamic).length) || this.bindings.length) { + if (!usesSpread && (this.attributes.filter(a => a.isDynamic).length || this.bindings.length)) { updates.push(`var ${name_changes} = {};`); } @@ -209,7 +209,7 @@ export default class Component extends Node { updates.push(deindent` var ${name_changes} = ${allDependencies.size === 1 ? `${conditions}` : `(${conditions})`} ? @getSpreadUpdate(${levels}, [ ${changes.join(',\n')} - ]) : ${name_changes}; + ]) : {}; `); } else { this.attributes diff --git a/test/runtime/samples/spread-component-with-bind/Widget.html b/test/runtime/samples/spread-component-with-bind/Widget.html new file mode 100644 index 0000000000..7d9b108a1a --- /dev/null +++ b/test/runtime/samples/spread-component-with-bind/Widget.html @@ -0,0 +1,2 @@ +

{value}

+ \ No newline at end of file diff --git a/test/runtime/samples/spread-component-with-bind/_config.js b/test/runtime/samples/spread-component-with-bind/_config.js new file mode 100644 index 0000000000..12a400b755 --- /dev/null +++ b/test/runtime/samples/spread-component-with-bind/_config.js @@ -0,0 +1,18 @@ +export default { + html: ` +

foo

+ + `, + + test (assert, component, target, window) { + const input = target.querySelector('input'); + + input.value = 'bar'; + input.dispatchEvent(new window.Event('input')); + + assert.htmlEqual(target.innerHTML, ` +

bar

+ + `); + } +}; diff --git a/test/runtime/samples/spread-component-with-bind/main.html b/test/runtime/samples/spread-component-with-bind/main.html new file mode 100644 index 0000000000..97ad6f7e44 --- /dev/null +++ b/test/runtime/samples/spread-component-with-bind/main.html @@ -0,0 +1,15 @@ + + + \ No newline at end of file