mirror of https://github.com/sveltejs/svelte
When no expression is used in a class directive the class name will be used to evaluate whether the class should be added/removed. E.g. the following will add the class "active" when you call `component.set({ active });`. ```html <div class:active></div> ```pull/1695/head
parent
0f171a5f3e
commit
4ec85bb8cc
@ -0,0 +1,16 @@
|
||||
export default {
|
||||
data: {
|
||||
isActive: true,
|
||||
isSelected: true,
|
||||
myClass: 'one two'
|
||||
},
|
||||
html: `<div class="one two is-active isSelected"></div>`,
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
component.set({ isActive: false });
|
||||
|
||||
assert.htmlEqual( target.innerHTML, `
|
||||
<div class="one two isSelected"></div>
|
||||
` );
|
||||
}
|
||||
};
|
@ -0,0 +1 @@
|
||||
<div class="{ myClass }" class:is-active class:isSelected class:not-used></div>
|
Loading…
Reference in new issue