Skip to content

fix: allow setting i18n before upgrading element#11325

Merged
web-padawan merged 1 commit intomainfrom
fix/set-i18n-before-upgrade
Mar 11, 2026
Merged

fix: allow setting i18n before upgrading element#11325
web-padawan merged 1 commit intomainfrom
fix/set-i18n-before-upgrade

Conversation

@sissbruecker
Copy link
Copy Markdown
Contributor

Description

#11178 caused a regression where setting i18n before upgrading an element results in __effectiveI18n not being calculated and the i18n setter not working properly afterwards. This is currently reproducable in the side nav dev page where rendering child items is broken because __effectiveI18n is undefined. It looks like the property needs to be declared to make Lit remove the data property during the upgrade, which otherwise shadows the custom setter.

This restores the i18n property declaration.

Type of change

  • Bugfix

@sonarqubecloud
Copy link
Copy Markdown

return {
// Even though the property is overridden by a custom getter/setter, it needs to be declared here to initialize
// __effectiveI18n properly if the i18n property is set before upgrading the element.
i18n: {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property would be public now, which also make CEM work. Not sure if that has any other side effects, for example when generating React components.


static get observedAttributes() {
return [...super.observedAttributes, 'i18n'];
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting per attribute seems to be covered by Lit now. The only thing that doesn't work is setting invalid JSON, removed the test case for that as I think that setting the I18N per attribute is in general not common or something to encourage.

@web-padawan web-padawan merged commit 9e51f0d into main Mar 11, 2026
10 checks passed
@web-padawan web-padawan deleted the fix/set-i18n-before-upgrade branch March 11, 2026 14:06
@vaadin-bot
Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.1.0-beta3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants