Use a block scoped unique name for the context

pull/912/head
esarbanis 7 years ago
parent e63529683d
commit 9218f20330

4
.gitignore vendored

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

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

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

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

@ -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]);
}
};

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