Commit 4bf04d0
tech(pat-upload): lazify pattern, split registration from implementation
pat-upload contributed ~17KB src to the eager patterns chunk on every page,
though the upload UI only appears in folder contents and upload dialogs.
Split it into a thin registration module and upload--implementation.js
holding the jquery/underscore/i18n wiring and the lazily-loaded Dropzone
integration. The thin module keeps registering the .pat-upload trigger and
grafts the implementation prototype on first match. Public options and
emitted markup are unchanged.
pat-structure, pat-relateditems and the contentbrowser app construct upload
imperatively (new Upload(...)) and use the instance right away. The
implementation therefore stays a constructable Base.extend pattern and those
callers import it directly, so new Upload() yields a fully formed instance
synchronously. Registry.register is first-wins, so the eagerly imported thin
module remains the registered .pat-upload pattern; the implementation is
only reached via lazy chunks (the structure app view, the contentbrowser
component and the relateditems dynamic import).
Add a regression test asserting the implementation is constructable and
exposes its methods synchronously.
The implementation now loads only where a .pat-upload element exists.1 parent 175c7bd commit 4bf04d0
6 files changed
Lines changed: 548 additions & 494 deletions
File tree
- src/pat
- contentbrowser/src
- structure/js/views
- upload
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
0 commit comments