diff --git a/src/generators/dom/visitors/Element/Binding.ts b/src/generators/dom/visitors/Element/Binding.ts index b3c72fd608..945145cb64 100644 --- a/src/generators/dom/visitors/Element/Binding.ts +++ b/src/generators/dom/visitors/Element/Binding.ts @@ -87,8 +87,16 @@ export default function visitBinding( const { name } = getObject(attribute.value); const tailSnippet = getTailSnippet(attribute.value); - updateElement = deindent` - var ${value} = #component.get( '${name}' )${tailSnippet}; + if (state.inEachBlock === true) { + 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 ) { var ${option} = ${state.parentNode}.options[#i]; diff --git a/test/runtime/samples/select-bind-in-array/_config.js b/test/runtime/samples/select-bind-in-array/_config.js new file mode 100644 index 0000000000..609fc4592a --- /dev/null +++ b/test/runtime/samples/select-bind-in-array/_config.js @@ -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' ); + } +}; diff --git a/test/runtime/samples/select-bind-in-array/main.html b/test/runtime/samples/select-bind-in-array/main.html new file mode 100644 index 0000000000..1a80b1afa0 --- /dev/null +++ b/test/runtime/samples/select-bind-in-array/main.html @@ -0,0 +1,6 @@ +{{#each items as item}} + +{{/each}}