0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

Merge pull request #912 from esarbanis/arg-name-clash

Use a block scoped unique name for the context solves #911
This commit is contained in:
Rich Harris 2017-11-12 14:45:34 -05:00 committed by GitHub
commit 60c13a6970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 2 deletions

4
.gitignore vendored
View File

@ -14,4 +14,6 @@ test/sourcemaps/samples/*/output.js.map
_actual.*
_actual-bundle.*
src/generators/dom/shared.ts
package-lock.json
package-lock.json
.idea/
*.iml

View File

@ -225,7 +225,7 @@ const preprocessors = {
);
listNames.set(node.context, listName);
const context = generator.getUniqueName(node.context);
const context = block.getUniqueName(node.context);
const contexts = new Map(block.contexts);
contexts.set(node.context, context);

View File

@ -0,0 +1,5 @@
<ul>
<li>animal</li>
<li>vegetable</li>
<li>mineral</li>
</ul>

View File

@ -0,0 +1,5 @@
<ul>
<li>animal</li>
<li>vegetable</li>
<li>mineral</li>
</ul>

View File

@ -0,0 +1,31 @@
export default {
data: {
things: {
foo: [
'animal',
'vegetable',
'mineral'
]
}
},
snapshot(target) {
const ul = target.querySelector('ul');
const lis = ul.querySelectorAll('li');
return {
ul,
lis
};
},
test(assert, target, snapshot) {
const ul = target.querySelector('ul');
const lis = ul.querySelectorAll('li');
assert.equal(ul, snapshot.ul);
assert.equal(lis[0], snapshot.lis[0]);
assert.equal(lis[1], snapshot.lis[1]);
assert.equal(lis[2], snapshot.lis[2]);
}
};

View File

@ -0,0 +1,5 @@
<ul>
{{#each things.foo as foo}}
<li>{{foo}}</li>
{{/each}}
</ul>