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:
commit
60c13a6970
4
.gitignore
vendored
4
.gitignore
vendored
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
5
test/hydration/samples/each-block-arg-clash/_after.html
Normal file
5
test/hydration/samples/each-block-arg-clash/_after.html
Normal file
@ -0,0 +1,5 @@
|
||||
<ul>
|
||||
<li>animal</li>
|
||||
<li>vegetable</li>
|
||||
<li>mineral</li>
|
||||
</ul>
|
5
test/hydration/samples/each-block-arg-clash/_before.html
Normal file
5
test/hydration/samples/each-block-arg-clash/_before.html
Normal file
@ -0,0 +1,5 @@
|
||||
<ul>
|
||||
<li>animal</li>
|
||||
<li>vegetable</li>
|
||||
<li>mineral</li>
|
||||
</ul>
|
31
test/hydration/samples/each-block-arg-clash/_config.js
Normal file
31
test/hydration/samples/each-block-arg-clash/_config.js
Normal 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]);
|
||||
}
|
||||
};
|
5
test/hydration/samples/each-block-arg-clash/main.html
Normal file
5
test/hydration/samples/each-block-arg-clash/main.html
Normal file
@ -0,0 +1,5 @@
|
||||
<ul>
|
||||
{{#each things.foo as foo}}
|
||||
<li>{{foo}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
Loading…
Reference in New Issue
Block a user