1
+ <script >
2
+ import Button from " ./Button.svelte"
3
+ import { createBubbler , handlers , preventDefault , stopPropagation , stopImmediatePropagation , self , trusted , once , passive , nonpassive } from ' svelte/legacy' ;
4
+
5
+ const bubble = createBubbler ();
6
+ </script >
7
+
8
+ <button onclick ={handlers (() => console .log (' hi' ), bubble (' click' ))}>click me</button >
9
+ <button onclick ={handlers (function (){ console .log (' hi' ) }, bubble (' click' ))}>click me</button >
10
+ <button onclick ={handlers (() => console .log (' before' ), bubble (' click' ), () => console .log (' after' ))}
11
+ >click me</button
12
+ >
13
+ <button onclick ={handlers (bubble (' click' ), foo )}>click me</button >
14
+ <button onclick ={bubble (' click' )}>click me</button >
15
+
16
+ <button ondblclick ={() => console .log (' hi' )}>click me</button >
17
+ <button ontoggle ={bubble (' toggle' )}>click me</button >
18
+ <button oncustom-event ={() => ' hi' }>click me</button >
19
+ <button oncustom-event-bubble ={bubble (' custom-event-bubble' )}>click me</button >
20
+
21
+ <button onclick ={preventDefault (() => (searching = true ))}>click me</button >
22
+ <button onclick ={preventDefault (() => ' ' )}>click me</button >
23
+ <button onclick ={stopPropagation (() => {})}>click me</button >
24
+ <button onclick ={stopImmediatePropagation (() => ' ' )}>click me</button >
25
+ <button onclickcapture ={() => ' ' }>click me</button >
26
+ <button onclick ={self (() => ' ' )}>click me</button >
27
+ <button onclick ={trusted (() => ' ' )}>click me</button >
28
+ <button onclick ={once (() => ' ' )}>click me</button >
29
+
30
+ <button onclick ={stopPropagation (preventDefault (() => ' ' ))}>click me</button >
31
+ <button onclick ={stopImmediatePropagation (stopPropagation (() => {}))}>click me</button >
32
+ <button onclick ={self (stopImmediatePropagation (() => ' ' ))}>click me</button >
33
+ <button onclick ={trusted (self (() => ' ' ))}>click me</button >
34
+ <button onclick ={trusted (self (() => ' ' ))}>click me</button >
35
+ <button onclick ={once (trusted (() => ' ' ))}>click me</button >
36
+ <button onclick ={once (preventDefault (() => ' ' ))}>click me</button >
37
+
38
+ <button use:passive ={[' click' , () => bubble (' click' )]}>click me</button >
39
+ <button use:nonpassive ={[' click' , () => bubble (' click' )]}>click me</button >
40
+ <button use:passive ={[' click' , () => ()=> ' ' ]}>click me</button >
41
+ <button use:nonpassive ={[' click' , () => ()=> ' ' ]}>click me</button >
42
+ <button use:passive ={[' click' , () => foo ]}>click me</button >
43
+ <button use:nonpassive ={[' click' , () => foo ]}>click me</button >
44
+ <button use:passive ={[' click' , () => stopPropagation (()=> ' ' )]}>click me</button >
45
+ <button use:nonpassive ={[' click' , () => trusted (()=> ' ' )]}>click me</button >
46
+
47
+ <button
48
+ use:passive ={[' click' , () => ()=> ' ' ]}
49
+ onclick ={handlers (bubble (' click' ), ()=> ' ' )}
50
+ >click me</button >
51
+
52
+ <button
53
+ use:nonpassive ={[' click' , () => ()=> ' ' ]}
54
+ onclick ={handlers (bubble (' click' ), ()=> {
55
+ return ' multiline' ;
56
+ })}
57
+ >click me</button >
58
+
59
+
60
+ <button
61
+ onclick ={handlers (bubble (' click' ), foo , ()=> ' ' , once (trusted (preventDefault (()=> ' ' ))))}
62
+ onblur ={handlers (foo , once (trusted (preventDefault (bubble (' blur' )))))}
63
+ >
64
+ click me
65
+ </button >
66
+
67
+
68
+ <Button on:click ={() => ' leave untouched' } on:click >click me</Button >
69
+
70
+ <div >
71
+ <button
72
+ onclick ={() => {
73
+ console .log (' hi' );
74
+ }}>click me</button
75
+ >
76
+ <button
77
+ onclick ={preventDefault (() => {
78
+ console .log (' hi' );
79
+ })}>click me</button
80
+ >
81
+ <button onclick ={preventDefault (() => (count += 1 ))}>click me</button >
82
+ </div >
0 commit comments