mirror of https://github.com/sveltejs/svelte
Merge pull request #1797 from sveltejs/gh-1793
recognise dependencies in class directivespull/1811/head
commit
d49f5f2136
@ -0,0 +1,21 @@
|
||||
export default {
|
||||
data: {
|
||||
things: ['one', 'two', 'three'],
|
||||
selected: 'two'
|
||||
},
|
||||
|
||||
html: `
|
||||
<div></div>
|
||||
<div class="selected"></div>
|
||||
<div></div>
|
||||
`,
|
||||
|
||||
test(assert, component, target) {
|
||||
component.set({ selected: 'three' });
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<div></div>
|
||||
<div class=""></div>
|
||||
<div class="selected"></div>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
{#each things as thing}
|
||||
<div class:selected="selected === thing"></div>
|
||||
{/each}
|
@ -0,0 +1,21 @@
|
||||
export default {
|
||||
data: {
|
||||
items: [
|
||||
'whatever'
|
||||
],
|
||||
foo: 'wrong',
|
||||
bar: 'right'
|
||||
},
|
||||
|
||||
test(assert, component, target, window) {
|
||||
const button = target.querySelector('button');
|
||||
const event = new window.MouseEvent('click');
|
||||
|
||||
button.dispatchEvent(event);
|
||||
assert.equal(component.get().foo, 'right');
|
||||
|
||||
component.set({ bar: 'left' });
|
||||
button.dispatchEvent(event);
|
||||
assert.equal(component.get().foo, 'left');
|
||||
}
|
||||
};
|
@ -0,0 +1,5 @@
|
||||
{#each items as item}
|
||||
<button on:click='set({ foo: bar })'>{item}</button>
|
||||
{/each}
|
||||
|
||||
<p>foo: {foo}</p>
|
Loading…
Reference in new issue