Commit 235881f
committed
Extract delegate for
In preparation for [basecamp#1128][], this commit introduces a module-private
`Delegate` class to serve as a representation of what form integration
requires for the `<trix-editor>` custom element. The structure of the
`Delegate` class mirrors that of the `TrixEditorElement` from which its
contents are extracted.
First, there are the properties that mimic those of most form controls,
including:
* `labels`
* `form`
* `name`
* `value`
* `defaultValue`
* `type`
With the exception of `labels`, property access is mostly proxied
through the associated `<input type="hidden">` element (accessed through
its own `inputElement` property).
Next, the `Delegate` defines methods that correspond to the Custom
Element lifecycle events, including:
* `connectedCallback`
* `disconnectedCallback`
* `setFormValue`
The connected and disconnected callbacks mirror that of the
`TrixEditorElement` itself. These callbacks attach and remove event
listeners for `click` and `reset` events.
The `setFormValue` is named to correspond with
[ElementInternals.setFormValue][]. Along with introducing this callback
method, this commit renames the `TrixEditorElement.setInputElementValue`
method to `TrixEditorElement.setFormValue`.
In addition to renaming `setInputElementValue`, this commit also defines
`TrixEditorElement.formResetCallback` (along with other empty
callbacks), then implements `TrixEditorElement.reset` as an alias. The
name mirrors the [ElementInternals.formResetCallback][].
[basecamp#1128]: basecamp#1128
[ElementInternals.setFormValue]: https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue
[ElementInternals.formResetCallback]: https://web.dev/articles/more-capable-form-controls#void_formresetcallbackTrixEditorElement
1 parent 3f22606 commit 235881f
File tree
3 files changed
+147
-69
lines changed- src
- test/system
- trix
- controllers
- elements
3 files changed
+147
-69
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
394 | 400 | | |
395 | 401 | | |
396 | 402 | | |
| |||
440 | 446 | | |
441 | 447 | | |
442 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
443 | 457 | | |
444 | 458 | | |
445 | | - | |
| 459 | + | |
446 | 460 | | |
447 | 461 | | |
448 | 462 | | |
| |||
451 | 465 | | |
452 | 466 | | |
453 | 467 | | |
454 | | - | |
| 468 | + | |
455 | 469 | | |
456 | 470 | | |
457 | 471 | | |
| |||
461 | 475 | | |
462 | 476 | | |
463 | 477 | | |
464 | | - | |
| 478 | + | |
465 | 479 | | |
466 | 480 | | |
467 | 481 | | |
| |||
514 | 528 | | |
515 | 529 | | |
516 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
517 | 537 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
163 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
164 | 267 | | |
165 | 268 | | |
166 | 269 | | |
| |||
174 | 277 | | |
175 | 278 | | |
176 | 279 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 280 | + | |
190 | 281 | | |
191 | 282 | | |
192 | 283 | | |
| |||
204 | 295 | | |
205 | 296 | | |
206 | 297 | | |
207 | | - | |
| 298 | + | |
208 | 299 | | |
209 | 300 | | |
210 | 301 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 302 | + | |
222 | 303 | | |
223 | 304 | | |
224 | 305 | | |
225 | 306 | | |
226 | 307 | | |
227 | 308 | | |
228 | 309 | | |
229 | | - | |
| 310 | + | |
230 | 311 | | |
231 | 312 | | |
232 | 313 | | |
233 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
234 | 319 | | |
235 | 320 | | |
236 | 321 | | |
| |||
246 | 331 | | |
247 | 332 | | |
248 | 333 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 334 | + | |
| 335 | + | |
253 | 336 | | |
254 | 337 | | |
255 | 338 | | |
| |||
264 | 347 | | |
265 | 348 | | |
266 | 349 | | |
267 | | - | |
| 350 | + | |
268 | 351 | | |
269 | 352 | | |
270 | 353 | | |
271 | 354 | | |
272 | | - | |
273 | | - | |
| 355 | + | |
274 | 356 | | |
275 | 357 | | |
276 | 358 | | |
277 | 359 | | |
278 | 360 | | |
279 | 361 | | |
280 | | - | |
281 | | - | |
| 362 | + | |
282 | 363 | | |
283 | 364 | | |
284 | 365 | | |
285 | 366 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 367 | + | |
293 | 368 | | |
294 | 369 | | |
295 | | - | |
296 | | - | |
297 | | - | |
| 370 | + | |
298 | 371 | | |
299 | 372 | | |
300 | | - | |
301 | | - | |
| 373 | + | |
302 | 374 | | |
303 | 375 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 376 | + | |
| 377 | + | |
320 | 378 | | |
321 | 379 | | |
322 | 380 | | |
323 | | - | |
| 381 | + | |
324 | 382 | | |
325 | 383 | | |
0 commit comments