@@ -9,7 +9,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
9
9
<div id="outside"></div>
10
10
`
11
11
async "test different syntaxes for once action" ( ) {
12
- this . actionValue = "click->c#log:once d#log2:once c#log3:once"
12
+ this . setAction ( this . buttonElement , "click->c#log:once d#log2:once c#log3:once" )
13
13
14
14
await this . nextFrame
15
15
await this . triggerEvent ( this . buttonElement , "click" )
@@ -23,7 +23,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
23
23
}
24
24
25
25
async "test mix once and standard actions" ( ) {
26
- this . actionValue = "c#log:once d#log2 c#log3"
26
+ this . setAction ( this . buttonElement , "c#log:once d#log2 c#log3" )
27
27
28
28
await this . nextFrame
29
29
await this . triggerEvent ( this . buttonElement , "click" )
@@ -39,7 +39,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
39
39
}
40
40
41
41
async "test stop propagation with once" ( ) {
42
- this . actionValue = "c#stop:once c#log"
42
+ this . setAction ( this . buttonElement , "c#stop:once c#log" )
43
43
44
44
await this . nextFrame
45
45
await this . triggerEvent ( this . buttonElement , "click" )
@@ -57,7 +57,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
57
57
}
58
58
59
59
async "test global once actions" ( ) {
60
- this . actionValue = "keydown@window->c#log:once"
60
+ this . setAction ( this . buttonElement , "keydown@window->c#log:once" )
61
61
62
62
await this . nextFrame
63
63
await this . triggerEvent ( "#outside" , "keydown" )
@@ -67,13 +67,13 @@ export default class EventOptionsTests extends LogControllerTestCase {
67
67
}
68
68
69
69
async "test edge case when updating action list with setAttribute preserves once history" ( ) {
70
- this . actionValue = "c#log:once"
70
+ this . setAction ( this . buttonElement , "c#log:once" )
71
71
await this . nextFrame
72
72
await this . triggerEvent ( this . buttonElement , "click" )
73
73
await this . triggerEvent ( this . buttonElement , "click" )
74
74
75
75
//modify with a setAttribute and c#log should not be called anyhow
76
- this . actionValue = "c#log2 c#log:once d#log"
76
+ this . setAction ( this . buttonElement , "c#log2 c#log:once d#log" )
77
77
await this . nextFrame
78
78
await this . triggerEvent ( this . buttonElement , "click" )
79
79
@@ -85,15 +85,15 @@ export default class EventOptionsTests extends LogControllerTestCase {
85
85
}
86
86
87
87
async "test default passive action" ( ) {
88
- this . actionValue = "scroll->c#logPassive:passive"
88
+ this . setAction ( this . buttonElement , "scroll->c#logPassive:passive" )
89
89
await this . nextFrame
90
90
91
91
await this . triggerEvent ( this . buttonElement , "scroll" , { setDefaultPrevented : false } )
92
92
this . assertActions ( { name : "logPassive" , eventType : "scroll" , passive : true } )
93
93
}
94
94
95
95
async "test global passive actions" ( ) {
96
- this . actionValue = "mouseup@window->c#logPassive:passive"
96
+ this . setAction ( this . buttonElement , "mouseup@window->c#logPassive:passive" )
97
97
await this . nextFrame
98
98
99
99
await this . triggerEvent ( "#outside" , "mouseup" , { setDefaultPrevented : false } )
@@ -102,7 +102,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
102
102
103
103
async "test passive false actions" ( ) {
104
104
// by default touchmove is true in chrome
105
- this . actionValue = "touchmove@window->c#logPassive:!passive"
105
+ this . setAction ( this . buttonElement , "touchmove@window->c#logPassive:!passive" )
106
106
await this . nextFrame
107
107
108
108
await this . triggerEvent ( "#outside" , "touchmove" , { setDefaultPrevented : false } )
@@ -111,7 +111,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
111
111
112
112
async "test multiple options" ( ) {
113
113
// by default touchmove is true in chrome
114
- this . actionValue = "touchmove@window->c#logPassive:once:!passive"
114
+ this . setAction ( this . buttonElement , "touchmove@window->c#logPassive:once:!passive" )
115
115
await this . nextFrame
116
116
117
117
await this . triggerEvent ( "#outside" , "touchmove" , { setDefaultPrevented : false } )
@@ -120,7 +120,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
120
120
}
121
121
122
122
async "test wrong options are silently ignored" ( ) {
123
- this . actionValue = "c#log:wrong:verywrong"
123
+ this . setAction ( this . buttonElement , "c#log:wrong:verywrong" )
124
124
await this . nextFrame
125
125
await this . triggerEvent ( this . buttonElement , "click" )
126
126
await this . triggerEvent ( this . buttonElement , "click" )
@@ -132,8 +132,8 @@ export default class EventOptionsTests extends LogControllerTestCase {
132
132
}
133
133
134
134
async "test stop option with implicit event" ( ) {
135
- this . elementActionValue = "click->c#log"
136
- this . actionValue = "c#log2:stop"
135
+ this . setAction ( this . element , "click->c#log" )
136
+ this . setAction ( this . buttonElement , "c#log2:stop" )
137
137
await this . nextFrame
138
138
139
139
await this . triggerEvent ( this . buttonElement , "click" )
@@ -144,8 +144,8 @@ export default class EventOptionsTests extends LogControllerTestCase {
144
144
}
145
145
146
146
async "test stop option with explicit event" ( ) {
147
- this . elementActionValue = "keydown->c#log"
148
- this . actionValue = "keydown->c#log2:stop"
147
+ this . setAction ( this . element , "keydown->c#log" )
148
+ this . setAction ( this . buttonElement , "keydown->c#log2:stop" )
149
149
await this . nextFrame
150
150
151
151
await this . triggerEvent ( this . buttonElement , "keydown" )
@@ -156,8 +156,8 @@ export default class EventOptionsTests extends LogControllerTestCase {
156
156
}
157
157
158
158
async "test event propagation without stop option" ( ) {
159
- this . elementActionValue = "click->c#log"
160
- this . actionValue = "c#log2"
159
+ this . setAction ( this . element , "click->c#log" )
160
+ this . setAction ( this . buttonElement , "c#log2" )
161
161
await this . nextFrame
162
162
163
163
await this . triggerEvent ( this . buttonElement , "click" )
@@ -169,7 +169,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
169
169
}
170
170
171
171
async "test prevent option with implicit event" ( ) {
172
- this . actionValue = "c#log:prevent"
172
+ this . setAction ( this . buttonElement , "c#log:prevent" )
173
173
await this . nextFrame
174
174
175
175
await this . triggerEvent ( this . buttonElement , "click" )
@@ -180,7 +180,7 @@ export default class EventOptionsTests extends LogControllerTestCase {
180
180
}
181
181
182
182
async "test prevent option with explicit event" ( ) {
183
- this . actionValue = "keyup->c#log:prevent"
183
+ this . setAction ( this . buttonElement , "keyup->c#log:prevent" )
184
184
await this . nextFrame
185
185
186
186
await this . triggerEvent ( this . buttonElement , "keyup" )
@@ -190,12 +190,8 @@ export default class EventOptionsTests extends LogControllerTestCase {
190
190
)
191
191
}
192
192
193
- set actionValue ( value : string ) {
194
- this . buttonElement . setAttribute ( "data-action" , value )
195
- }
196
-
197
- set elementActionValue ( value : string ) {
198
- this . element . setAttribute ( "data-action" , value )
193
+ setAction ( element : Element , value : string ) {
194
+ element . setAttribute ( "data-action" , value )
199
195
}
200
196
201
197
get element ( ) {
0 commit comments