pull/6898/head
Yuichiro Yamashita 5 years ago
parent 84d9f83698
commit d65da8d174

@ -0,0 +1,17 @@
export default {
props: {
tag: 'div'
},
html: '<div style="color: red;">Foo</div>',
test({ assert, component, target }) {
component.tag = 'h1';
assert.htmlEqual(
target.innerHTML,
`
<h1 style="color: red;">Foo</h1>
`
);
}
};

@ -0,0 +1,5 @@
<script>
export let tag = 'div';
</script>
<svelte:element this={tag} style="color: red;">Foo</svelte:element>

@ -0,0 +1,23 @@
let clicked = false;
function handler() {
clicked = true;
}
export default {
props: {
tag: 'div',
handler
},
html: '<div>Foo</div>',
test({ assert, component, target }) {
assert.equal(clicked, false);
component.tag = 'button';
const button = target.querySelector('button');
const click = new window.MouseEvent('click');
button.dispatchEvent(click);
assert.equal(clicked, true);
}
};

@ -0,0 +1,6 @@
<script>
export let tag;
export let handler;
</script>
<svelte:element this={tag} on:click={handler}>Foo</svelte:element>
Loading…
Cancel
Save