mirror of https://github.com/sveltejs/svelte
Merge pull request #1064 from sveltejs/gh-1063
prevent main fragment being created twicepull/1072/head
commit
8d0b4a17e4
@ -0,0 +1,13 @@
|
|||||||
|
<button on:click='set({ count: count + 1 })'>count: {{count}}</button>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
tag: 'my-counter',
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
count: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,12 @@
|
|||||||
|
<Counter bind:count/>
|
||||||
|
<p>clicked {{count}} times</p>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Counter from './Counter.html';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
tag: 'my-app',
|
||||||
|
|
||||||
|
components: { Counter }
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,17 @@
|
|||||||
|
import * as assert from 'assert';
|
||||||
|
import './main.html';
|
||||||
|
|
||||||
|
export default function (target) {
|
||||||
|
target.innerHTML = '<my-app/>';
|
||||||
|
const el = target.querySelector('my-app');
|
||||||
|
const counter = el.shadowRoot.querySelector('my-counter');
|
||||||
|
const button = counter.shadowRoot.querySelector('button');
|
||||||
|
|
||||||
|
assert.equal(counter.count, 0);
|
||||||
|
assert.equal(counter.shadowRoot.innerHTML, `<button>count: 0</button>`);
|
||||||
|
|
||||||
|
button.dispatchEvent(new MouseEvent('click'));
|
||||||
|
|
||||||
|
assert.equal(counter.count, 1);
|
||||||
|
assert.equal(counter.shadowRoot.innerHTML, `<button>count: 1</button>`);
|
||||||
|
}
|
Loading…
Reference in new issue