|
33 | 33 | window.addEventListener ('message', handler);
|
34 | 34 | // with a comment
|
35 | 35 | window.addEventListener/* foo */('message', handler);
|
| 36 | +
|
| 37 | + // with options |
| 38 | + window.addEventListener('message', handler, { once: true }); |
36 | 39 | </script>
|
37 | 40 |
|
38 | 41 | <button onclick={onClick}>Hello</button>
|
|
71 | 74 | window.addEventListener ('message', handler);
|
72 | 75 | // with a comment
|
73 | 76 | window.addEventListener/* foo */('message', handler);
|
| 77 | +
|
| 78 | + // with options |
| 79 | + window.addEventListener('message', handler, { once: true }); |
74 | 80 | </script>
|
75 | 81 |
|
76 | 82 | <button onclick={onClick}>Hello</button>
|
|
109 | 115 | window.addEventListener ('message', handler);
|
110 | 116 | // with a comment
|
111 | 117 | window.addEventListener/* foo */('message', handler);
|
| 118 | +
|
| 119 | + // with options |
| 120 | + window.addEventListener('message', handler, { once: true }); |
112 | 121 | </script>
|
113 | 122 |
|
114 | 123 | <button onclick={onClick}>Hello</button>
|
|
147 | 156 | window.addEventListener ('message', handler);
|
148 | 157 | // with a comment
|
149 | 158 | window.addEventListener/* foo */('message', handler);
|
| 159 | +
|
| 160 | + // with options |
| 161 | + window.addEventListener('message', handler, { once: true }); |
150 | 162 | </script>
|
151 | 163 |
|
152 | 164 | <button onclick={onClick}>Hello</button>
|
|
185 | 197 | window.addEventListener ('message', handler);
|
186 | 198 | // with a comment
|
187 | 199 | window.addEventListener/* foo */('message', handler);
|
| 200 | +
|
| 201 | + // with options |
| 202 | + window.addEventListener('message', handler, { once: true }); |
188 | 203 | </script>
|
189 | 204 |
|
190 | 205 | <button onclick={onClick}>Hello</button>
|
|
223 | 238 | on (window, 'message', handler);
|
224 | 239 | // with a comment
|
225 | 240 | window.addEventListener/* foo */('message', handler);
|
| 241 | +
|
| 242 | + // with options |
| 243 | + window.addEventListener('message', handler, { once: true }); |
226 | 244 | </script>
|
227 | 245 |
|
228 | 246 | <button onclick={onClick}>Hello</button>
|
|
261 | 279 | window.addEventListener ('message', handler);
|
262 | 280 | // with a comment
|
263 | 281 | on/* foo */(window, 'message', handler);
|
| 282 | +
|
| 283 | + // with options |
| 284 | + window.addEventListener('message', handler, { once: true }); |
| 285 | + </script> |
| 286 | +
|
| 287 | + <button onclick={onClick}>Hello</button> |
| 288 | +- message: Do not use `addEventListener`. Use the `on` function from |
| 289 | + `svelte/events` instead. |
| 290 | + line: 31 |
| 291 | + column: 2 |
| 292 | + suggestions: |
| 293 | + - desc: Use `on` from `svelte/events` instead |
| 294 | + output: | |
| 295 | + <script> |
| 296 | + const handler = (ev) => { |
| 297 | + console.log(ev); |
| 298 | + }; |
| 299 | +
|
| 300 | + function onClick(event) { |
| 301 | + const target = event.currentTarget; |
| 302 | +
|
| 303 | + const deepObj = { |
| 304 | + deep: { |
| 305 | + obj: { |
| 306 | + target |
| 307 | + } |
| 308 | + } |
| 309 | + }; |
| 310 | +
|
| 311 | + target.addEventListener('focus', handler); |
| 312 | + deepObj.deep.obj.target.addEventListener('focus', handler); |
| 313 | + } |
| 314 | +
|
| 315 | + addEventListener('message', handler); |
| 316 | + window.addEventListener('message', handler); |
| 317 | + document.addEventListener('visibilitychange', handler); |
| 318 | +
|
| 319 | + // with a load of whitespace |
| 320 | + window.addEventListener ('message', handler); |
| 321 | + // with a comment |
| 322 | + window.addEventListener/* foo */('message', handler); |
| 323 | +
|
| 324 | + // with options |
| 325 | + on(window, 'message', handler, { once: true }); |
264 | 326 | </script>
|
265 | 327 |
|
266 | 328 | <button onclick={onClick}>Hello</button>
|
0 commit comments