fix: migrate deprecated performUpdate api to scheduleUpdate

This commit is contained in:
Thijs Louisse 2024-02-21 17:25:02 +01:00 committed by Thijs Louisse
parent 9b9e78951f
commit eb46728826
3 changed files with 14 additions and 9 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/ui': patch
---
migrate deprecated `performUpdate` api to `scheduleUpdate`

View file

@ -163,20 +163,20 @@ export const runRegistrationSuite = customConfig => {
}); });
it('works for components that have a delayed render', async () => { it('works for components that have a delayed render', async () => {
class PerformUpdate extends FormRegistrarMixin(LitElement) { class ScheduleUpdate extends FormRegistrarMixin(LitElement) {
async performUpdate() { async scheduleUpdate() {
// eslint-disable-next-line no-promise-executor-return // eslint-disable-next-line no-promise-executor-return
await new Promise(resolve => setTimeout(() => resolve(undefined), 10)); await new Promise(resolve => setTimeout(() => resolve(undefined), 10));
await super.performUpdate(); await super.scheduleUpdate();
} }
render() { render() {
return html`<slot></slot>`; return html`<slot></slot>`;
} }
} }
const tagWrapperString = defineCE(PerformUpdate); const tagWrapperString = defineCE(ScheduleUpdate);
const tagWrapper = unsafeStatic(tagWrapperString); const tagWrapper = unsafeStatic(tagWrapperString);
const el = /** @type {PerformUpdate} */ ( const el = /** @type {ScheduleUpdate} */ (
await fixture(html` await fixture(html`
<${tagWrapper}> <${tagWrapper}>
<${childTag}></${childTag}> <${childTag}></${childTag}>
@ -359,10 +359,10 @@ export const runRegistrationSuite = customConfig => {
it('works for portals that have a delayed render', async () => { it('works for portals that have a delayed render', async () => {
const delayedPortalString = defineCE( const delayedPortalString = defineCE(
class extends FormRegistrarPortalMixin(LitElement) { class extends FormRegistrarPortalMixin(LitElement) {
async performUpdate() { async scheduleUpdate() {
// eslint-disable-next-line no-promise-executor-return // eslint-disable-next-line no-promise-executor-return
await new Promise(resolve => setTimeout(() => resolve(undefined), 10)); await new Promise(resolve => setTimeout(() => resolve(undefined), 10));
await super.performUpdate(); await super.scheduleUpdate();
} }
render() { render() {

View file

@ -64,11 +64,11 @@ const LocalizeMixinImplementation = superclass =>
* hook into LitElement to only render once all translations are loaded * hook into LitElement to only render once all translations are loaded
* @returns {Promise.<void>} * @returns {Promise.<void>}
*/ */
async performUpdate() { async scheduleUpdate() {
if (Object.getPrototypeOf(this).constructor.waitForLocalizeNamespaces) { if (Object.getPrototypeOf(this).constructor.waitForLocalizeNamespaces) {
await this.localizeNamespacesLoaded; await this.localizeNamespacesLoaded;
} }
super.performUpdate(); super.scheduleUpdate();
} }
connectedCallback() { connectedCallback() {