Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use _set, not set, when updating child components #728

Merged
merged 1 commit into from
Jul 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/generators/dom/visitors/Component/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
`);
}

Expand Down
18 changes: 18 additions & 0 deletions test/runtime/samples/component-binding-blowback-c/Nested.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<li>
{{yield}}
</li>

<script>
const initialValues = {
'id-0': 'zero',
'id-1': 'one',
'id-2': 'two',
'id-3': 'three'
};

export default {
oncreate() {
this.set({ value: initialValues[this.get('id')] });
}
};
</script>
33 changes: 33 additions & 0 deletions test/runtime/samples/component-binding-blowback-c/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export default {
'skip-ssr': true,

data: {
count: 3
},

html: `
<input type='number'>
<ol>
<li>id-2: value is two</li>
<li>id-1: value is one</li>
<li>id-0: value is zero</li>
</ol>
`,

test (assert, component, target, window) {
const input = target.querySelector('input');

input.value = 4;
input.dispatchEvent(new window.Event('input'));

assert.htmlEqual(target.innerHTML, `
<input type='number'>
<ol>
<li>id-3: value is three</li>
<li>id-2: value is two</li>
<li>id-1: value is one</li>
<li>id-0: value is zero</li>
</ol>
`);
}
};
34 changes: 34 additions & 0 deletions test/runtime/samples/component-binding-blowback-c/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<input type='number' bind:value='count'>

<ol>
{{#each ids as object @id}}
<Nested bind:value='idToValue[object.id]' id='{{object.id}}'>
{{object.id}}: value is {{idToValue[object.id]}}
</Nested>
{{/each}}
</ol>

<script>
import Nested from './Nested.html';

export default {
data() {
return {
idToValue: Object.create(null)
};
},

computed: {
ids(count) {
return new Array(count)
.fill(null)
.map((_, i) => ({ id: 'id-' + i}))
.reverse();
}
},

components: {
Nested
}
};
</script>