From 7569cf60c0a6434f621185beec5607799fa47853 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 19 Nov 2016 19:06:17 -0500 Subject: [PATCH] fix dynamic attributes --- compiler/generate/index.js | 2 +- test/compiler/attribute-dynamic-multiple/_config.js | 10 ++++++++++ test/compiler/attribute-dynamic-multiple/main.svelte | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/compiler/attribute-dynamic-multiple/_config.js create mode 100644 test/compiler/attribute-dynamic-multiple/main.svelte diff --git a/compiler/generate/index.js b/compiler/generate/index.js index df742d162e..5e8e23bde3 100644 --- a/compiler/generate/index.js +++ b/compiler/generate/index.js @@ -174,7 +174,7 @@ export default function generate ( parsed, template ) { return JSON.stringify( chunk.data ); } else { contextualise( code, chunk.expression, current.contexts, helpers ); - return `[✂${chunk.expression.start}-${chunk.expression.end}✂]`; + return `( [✂${chunk.expression.start}-${chunk.expression.end}✂] )`; } }).join( ' + ' ) ); diff --git a/test/compiler/attribute-dynamic-multiple/_config.js b/test/compiler/attribute-dynamic-multiple/_config.js new file mode 100644 index 0000000000..0cb7c908dd --- /dev/null +++ b/test/compiler/attribute-dynamic-multiple/_config.js @@ -0,0 +1,10 @@ +export default { + data: { + items: [ + { foo: true, bar: false }, + { foo: false, bar: true }, + { foo: true, bar: true } + ] + }, + html: `
1
2
3
` +}; diff --git a/test/compiler/attribute-dynamic-multiple/main.svelte b/test/compiler/attribute-dynamic-multiple/main.svelte new file mode 100644 index 0000000000..7133f1e330 --- /dev/null +++ b/test/compiler/attribute-dynamic-multiple/main.svelte @@ -0,0 +1,3 @@ +{{#each items as item, i}} +
{{i + 1}}
+{{/each}}