From cb030fd780d32991e3f9edf3593bfa8b8a143c93 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 29 Jul 2017 12:19:58 -0400 Subject: [PATCH] use _set, not set, when updating child components - fixes #721 --- .../dom/visitors/Component/Component.ts | 2 +- .../component-binding-blowback-c/Nested.html | 18 ++++++++++ .../component-binding-blowback-c/_config.js | 33 ++++++++++++++++++ .../component-binding-blowback-c/main.html | 34 +++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/component-binding-blowback-c/Nested.html create mode 100644 test/runtime/samples/component-binding-blowback-c/_config.js create mode 100644 test/runtime/samples/component-binding-blowback-c/main.html diff --git a/src/generators/dom/visitors/Component/Component.ts b/src/generators/dom/visitors/Component/Component.ts index 7145f5de36..a9fff4ee39 100644 --- a/src/generators/dom/visitors/Component/Component.ts +++ b/src/generators/dom/visitors/Component/Component.ts @@ -212,7 +212,7 @@ export default function visitComponent( ${updates.join('\n')} - if ( Object.keys( ${name}_changes ).length ) ${name}.set( ${name}_changes ); + if ( Object.keys( ${name}_changes ).length ) ${name}._set( ${name}_changes ); `); } diff --git a/test/runtime/samples/component-binding-blowback-c/Nested.html b/test/runtime/samples/component-binding-blowback-c/Nested.html new file mode 100644 index 0000000000..a1420a6916 --- /dev/null +++ b/test/runtime/samples/component-binding-blowback-c/Nested.html @@ -0,0 +1,18 @@ +
  • + {{yield}} +
  • + + diff --git a/test/runtime/samples/component-binding-blowback-c/_config.js b/test/runtime/samples/component-binding-blowback-c/_config.js new file mode 100644 index 0000000000..78c3e915fd --- /dev/null +++ b/test/runtime/samples/component-binding-blowback-c/_config.js @@ -0,0 +1,33 @@ +export default { + 'skip-ssr': true, + + data: { + count: 3 + }, + + html: ` + +
      +
    1. id-2: value is two
    2. +
    3. id-1: value is one
    4. +
    5. id-0: value is zero
    6. +
    + `, + + test (assert, component, target, window) { + const input = target.querySelector('input'); + + input.value = 4; + input.dispatchEvent(new window.Event('input')); + + assert.htmlEqual(target.innerHTML, ` + +
      +
    1. id-3: value is three
    2. +
    3. id-2: value is two
    4. +
    5. id-1: value is one
    6. +
    7. id-0: value is zero
    8. +
    + `); + } +}; diff --git a/test/runtime/samples/component-binding-blowback-c/main.html b/test/runtime/samples/component-binding-blowback-c/main.html new file mode 100644 index 0000000000..3cf809552b --- /dev/null +++ b/test/runtime/samples/component-binding-blowback-c/main.html @@ -0,0 +1,34 @@ + + +
      + {{#each ids as object @id}} + + {{object.id}}: value is {{idToValue[object.id]}} + + {{/each}} +
    + +