|
1 | 1 | <script> |
| 2 | + import { onMount } from 'svelte'; |
| 3 | +
|
2 | 4 | export let value = []; |
3 | 5 |
|
4 | | - function one(elem) { elem.addEventListener('input', () => { value.push('1'); }); } |
5 | | - function four(elem) { elem.addEventListener('input', () => { value.push('4'); }); } |
6 | | - function eight(elem) { elem.addEventListener('input', () => { value.push('8'); }); } |
7 | | - function twelve(elem) { elem.addEventListener('input', () => { value.push('12'); }); } |
8 | | - function fifteen(elem) { elem.addEventListener('input', () => { value.push('15'); }); } |
9 | | - function seventeen(elem) { elem.addEventListener('input', () => { value.push('17'); }); } |
| 6 | + function one(elem) { |
| 7 | + elem.addEventListener('input', () => { |
| 8 | + value.push('1'); |
| 9 | + }); |
| 10 | + } |
| 11 | + function four(elem) { |
| 12 | + elem.addEventListener('input', () => { |
| 13 | + value.push('4'); |
| 14 | + }); |
| 15 | + } |
| 16 | + function eight(elem) { |
| 17 | + elem.addEventListener('input', () => { |
| 18 | + value.push('8'); |
| 19 | + }); |
| 20 | + } |
| 21 | + function twelve(elem) { |
| 22 | + elem.addEventListener('input', () => { |
| 23 | + value.push('12'); |
| 24 | + }); |
| 25 | + } |
| 26 | + function fifteen(elem) { |
| 27 | + elem.addEventListener('input', () => { |
| 28 | + value.push('15'); |
| 29 | + }); |
| 30 | + } |
| 31 | + function seventeen(elem) { |
| 32 | + elem.addEventListener('input', () => { |
| 33 | + value.push('17'); |
| 34 | + }); |
| 35 | + } |
10 | 36 |
|
11 | 37 | const foo = { |
12 | | - set two(v) { value.push('2'); }, |
13 | | - set six(v) { value.push('6'); }, |
14 | | - set nine(v) { value.push('9'); }, |
15 | | - set eleven(v) { value.push('11'); }, |
16 | | - set thirteen(v) { value.push('13'); }, |
17 | | - set sixteen(v) { value.push('16'); }, |
| 38 | + set two(v) { |
| 39 | + value.push('2'); |
| 40 | + }, |
| 41 | + set six(v) { |
| 42 | + value.push('6'); |
| 43 | + }, |
| 44 | + set nine(v) { |
| 45 | + value.push('9'); |
| 46 | + }, |
| 47 | + set eleven(v) { |
| 48 | + value.push('11'); |
| 49 | + }, |
| 50 | + set thirteen(v) { |
| 51 | + value.push('13'); |
| 52 | + }, |
| 53 | + set sixteen(v) { |
| 54 | + value.push('16'); |
| 55 | + } |
| 56 | + }; |
| 57 | +
|
| 58 | + function three() { |
| 59 | + value.push('3'); |
| 60 | + } |
| 61 | + function five() { |
| 62 | + value.push('5'); |
| 63 | + } |
| 64 | + function seven() { |
| 65 | + value.push('7'); |
| 66 | + } |
| 67 | + function ten() { |
| 68 | + value.push('10'); |
| 69 | + } |
| 70 | + function fourteen() { |
| 71 | + value.push('14'); |
| 72 | + } |
| 73 | + function eighteen() { |
| 74 | + value.push('18'); |
18 | 75 | } |
19 | 76 |
|
20 | | - function three() { value.push('3'); } |
21 | | - function five() { value.push('5'); } |
22 | | - function seven() { value.push('7'); } |
23 | | - function ten() { value.push('10'); } |
24 | | - function fourteen() { value.push('14'); } |
25 | | - function eighteen() { value.push('18'); } |
| 77 | + let el; |
26 | 78 |
|
| 79 | + onMount(() => { |
| 80 | + // ensure that bind:this doesn't influence the order of directives |
| 81 | + // and isn't affected itself by an action being on the element |
| 82 | + value.push('bind:this ' + !!el); |
| 83 | + }); |
27 | 84 | </script> |
28 | 85 |
|
29 | 86 | <input use:one bind:value={foo.two} on:input={three} /> |
30 | 87 | <input use:four on:input={five} bind:value={foo.six} /> |
31 | 88 | <input on:input={seven} use:eight bind:value={foo.nine} /> |
32 | 89 | <input on:input={ten} bind:value={foo.eleven} use:twelve /> |
33 | 90 | <input bind:value={foo.thirteen} on:input={fourteen} use:fifteen /> |
34 | | -<input bind:value={foo.sixteen} use:seventeen on:input={eighteen} /> |
| 91 | +<input bind:this={el} bind:value={foo.sixteen} use:seventeen on:input={eighteen} /> |
0 commit comments