@@ -36,24 +36,22 @@ class Pattern extends BasePattern {
36
36
this . set_state ( ) ;
37
37
38
38
for ( const input of this . handler . getAllInputs ( ) ) {
39
+ // Note: One input can be a dependency for multiple other dependent
40
+ // elements. Therefore we need to bind the events not uniquely and
41
+ // add a uuid to the event bindings id.
42
+
39
43
events . add_event_listener (
40
44
input ,
41
- "change" ,
42
- `pat-depends--change--${ this . uuid } ` , // We need to support multiple events per dependant ...
43
- this . set_state . bind ( this )
44
- ) ;
45
- events . add_event_listener (
46
- input ,
47
- "keyup" ,
48
- `pat-depends--keyup--${ this . uuid } ` , // ... therefore we need to add a uuid to the event id ...
45
+ "input" ,
46
+ `pat-depends--input--${ this . uuid } ` ,
49
47
this . set_state . bind ( this )
50
48
) ;
51
49
52
50
if ( input . form ) {
53
51
events . add_event_listener (
54
52
input . form ,
55
53
"reset" ,
56
- `pat-depends--reset--${ this . uuid } ` , // ... to not override previously set event handlers.
54
+ `pat-depends--reset--${ this . uuid } ` ,
57
55
async ( ) => {
58
56
// TODO: note sure, what this timeout is for.
59
57
await utils . timeout ( 50 ) ;
@@ -77,8 +75,9 @@ class Pattern extends BasePattern {
77
75
const inputs = dom . find_inputs ( this . el ) ;
78
76
for ( const input of inputs ) {
79
77
input . disabled = false ;
80
- // Trigger the change event after disabling so that any other bound actions can react on that.
81
- input . dispatchEvent ( events . change_event ( ) ) ;
78
+ // Trigger the input after disabling so that any other bound
79
+ // actions can react on that.
80
+ input . dispatchEvent ( events . input_event ( ) ) ;
82
81
}
83
82
if ( this . el . tagName === "A" ) {
84
83
events . remove_event_listener ( this . el , "pat-depends--click" ) ;
@@ -96,8 +95,9 @@ class Pattern extends BasePattern {
96
95
const inputs = dom . find_inputs ( this . el ) ;
97
96
for ( const input of inputs ) {
98
97
input . disabled = true ;
99
- // Trigger the change event after disabling so that any other bound actions can react on that.
100
- input . dispatchEvent ( events . change_event ( ) ) ;
98
+ // Trigger the input after disabling so that any other bound
99
+ // actions can react on that.
100
+ input . dispatchEvent ( events . input_event ( ) ) ;
101
101
}
102
102
if ( this . el . tagName === "A" ) {
103
103
events . add_event_listener ( this . el , "click" , "pat-depends--click" , ( e ) =>
0 commit comments