diff --git a/src/compile/dom/index.ts b/src/compile/dom/index.ts index 3e201c1a7459..13e709b04f4b 100644 --- a/src/compile/dom/index.ts +++ b/src/compile/dom/index.ts @@ -89,10 +89,8 @@ export default function dom( } else { // computed property depends on entire state object — // these must go at the end - const arg = hasRestParam ? `@exclude(state, "${key}")` : `state`; - computationBuilder.addLine( - `if (this._differs(state.${key}, (state.${key} = %computed-${key}(${arg})))) changed.${key} = true;` + `if (this._differs(state.${key}, (state.${key} = %computed-${key}(@exclude(state, "${key}"))))) changed.${key} = true;` ); } }); diff --git a/test/runtime/samples/computed-whole-state/_config.js b/test/runtime/samples/computed-whole-state/_config.js new file mode 100644 index 000000000000..0281827b4ba0 --- /dev/null +++ b/test/runtime/samples/computed-whole-state/_config.js @@ -0,0 +1,25 @@ +export default { + html: ` +
{"wanted":2}+ `, + + test(assert, component, target) { + component.set({ + unwanted: 3, + wanted: 4, + }); + + assert.htmlEqual(target.innerHTML, ` +
{"wanted":4}+ `); + + component.set({ + unwanted: 5, + wanted: 6, + }); + + assert.htmlEqual(target.innerHTML, ` +
{"wanted":6}+ `); + }, +}; diff --git a/test/runtime/samples/computed-whole-state/main.html b/test/runtime/samples/computed-whole-state/main.html new file mode 100644 index 000000000000..476d11cc8bab --- /dev/null +++ b/test/runtime/samples/computed-whole-state/main.html @@ -0,0 +1,22 @@ +
{JSON.stringify(props)}+