Commit 6ec8c94
committed
fix(ui5-date-picker): prevent CLDR cache-poisoning and crash during language change
When setLanguage() is called without await, there is a race between the CLDR
fetch completing and re-renders still in the deferred render queue. A component
queued for rendering before the language change started would still call
onBeforeRendering / onAfterRendering with stale or missing locale data.
Two-layer fix:
1. UI5Element._render(): skip the render entirely for languageAware components
while getLanguageChangePending() is non-null. _invalidate() already blocks
new invalidations during this window, but components already in the render
queue (queued before the language change fired) could still reach _render().
This guard closes that gap — no lifecycle hooks are entered, and
reRenderAllUI5Elements({ languageAware: true }) re-renders them once CLDR
is ready.
2. getCachedLocaleDataInstance: attach attachLanguageChange(() => cache.clear())
so any cached LocaleData instances are discarded when the language changes.
This ensures the next call after CLDR loads gets a fresh, valid instance
rather than a stale one built against the old locale data.
Fixes the TypeError: Cannot read properties of undefined (reading
'ca-gregorian') seen in DatePicker Cypress tests when setLanguage is called
without await.1 parent c2c5ba3 commit 6ec8c94
4 files changed
Lines changed: 12 additions & 16 deletions
File tree
- packages
- base/src
- localization/src
- main/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
898 | 898 | | |
899 | 899 | | |
900 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
901 | 911 | | |
902 | 912 | | |
903 | 913 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 19 | | |
23 | 20 | | |
24 | 21 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 22 | + | |
30 | 23 | | |
31 | 24 | | |
32 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | 647 | | |
| 648 | + | |
653 | 649 | | |
654 | 650 | | |
655 | 651 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | 220 | | |
224 | 221 | | |
225 | 222 | | |
| |||
0 commit comments