Fix binding in each block

pull/723/head
Yury Zhuravlev 8 years ago
parent b8454de57f
commit 246b4d70dc

@ -87,8 +87,16 @@ export default function visitBinding(
const { name } = getObject(attribute.value); const { name } = getObject(attribute.value);
const tailSnippet = getTailSnippet(attribute.value); const tailSnippet = getTailSnippet(attribute.value);
updateElement = deindent` if (state.inEachBlock === true) {
var ${value} = #component.get( '${name}' )${tailSnippet}; updateElement = deindent`
var ${value} = ${snippet};
`;
} else {
updateElement = deindent`
var ${value} = #component.get( '${name}' )${tailSnippet};
`;
}
updateElement += `
for ( var #i = 0; #i < ${state.parentNode}.options.length; #i += 1 ) { for ( var #i = 0; #i < ${state.parentNode}.options.length; #i += 1 ) {
var ${option} = ${state.parentNode}.options[#i]; var ${option} = ${state.parentNode}.options[#i];

@ -0,0 +1,16 @@
const items = [ { id: 'a' }, { id: 'b' } ];
export default {
'skip-ssr': true,
data: {
items
},
test ( assert, component, target ) {
const items = component.get('items');
assert.equal( items[0].id, 'a' );
assert.equal( items[1].id, 'b' );
}
};

@ -0,0 +1,6 @@
{{#each items as item}}
<select bind:value="item.id">
<option value='a'>a</option>
<option value='b'>b</option>
</select>
{{/each}}
Loading…
Cancel
Save