mirror of https://github.com/sveltejs/svelte
parent
45f2890261
commit
1e9e843ca5
@ -0,0 +1,18 @@
|
||||
export default {
|
||||
html: `
|
||||
<div style="background-color: rgb(255, 0, 0);"></div>
|
||||
`,
|
||||
|
||||
test({ assert, target, window, component }) {
|
||||
const div = target.querySelector('div');
|
||||
const styles = window.getComputedStyle(div);
|
||||
assert.equal(styles.backgroundColor, 'rgb(255, 0, 0)');
|
||||
|
||||
{
|
||||
component.backgroundColor = 128;
|
||||
const div = target.querySelector('div');
|
||||
const styles = window.getComputedStyle(div);
|
||||
assert.equal(styles.backgroundColor, 'rgb(128, 0, 0)');
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,5 @@
|
||||
<script lang="ts">
|
||||
export let backgroundColor = 255;
|
||||
</script>
|
||||
|
||||
<div style:background-color="rgb({backgroundColor}, 0, 0)" {...$$restProps} />
|
@ -0,0 +1,11 @@
|
||||
export default {
|
||||
async test({ assert, target, window }) {
|
||||
const div = target.querySelector('div');
|
||||
const click = new window.MouseEvent('click');
|
||||
|
||||
assert.htmlEqual(target.innerHTML, '<div style="background: red;"></div>');
|
||||
await div.dispatchEvent(click);
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(target.innerHTML, '<div style=""></div>');
|
||||
}
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
let bg = "red";
|
||||
|
||||
const handle = () => {
|
||||
bg = undefined;
|
||||
};
|
||||
</script>
|
||||
|
||||
<div style:background={bg} on:click={handle}></div>
|
Loading…
Reference in new issue