Merge pull request #2349 from Panya/issue-2348

Pass block to the render of an expression in an attribute
pull/2364/head
Rich Harris 6 years ago committed by GitHub
commit c853e44130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -78,7 +78,7 @@ export default class AttributeWrapper {
// DRY it out if that's possible without introducing crazy indirection // DRY it out if that's possible without introducing crazy indirection
if (this.node.chunks.length === 1) { if (this.node.chunks.length === 1) {
// single {tag} — may be a non-string // single {tag} — may be a non-string
value = this.node.chunks[0].render(); value = this.node.chunks[0].render(block);
} else { } else {
// '{foo} {bar}' — treat as string concatenation // '{foo} {bar}' — treat as string concatenation
value = value =

@ -0,0 +1,12 @@
export default {
html: `
<select>
<option value="">please choose</option>
<option value="1">1</option>
<option disabled="" value="2">2</option>
<option value="3">3</option>
<option disabled="" value="4">4</option>
<option value="5">5</option>
</select>
`
};

@ -0,0 +1,11 @@
<script>
let available = [1, 2, 3, 4, 5];
let taken = [2, 4];
</script>
<select>
<option value="">please choose</option>
{#each available as a}
<option disabled="{!!taken.find(f => f == a)}" value="{a}">{a}</option>
{/each}
</select>
Loading…
Cancel
Save