Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always define custom element class version getter #7813

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

web-padawan
Copy link
Member

Description

This fixes an error with version listed as undefined when trying to re-define the same class with a different version:

Tried to define vaadin-iconset version undefined when version 24.5.0-alpha11 is already in use. Something will probably break.
console.error @ (index):5
defineCustomElement @ define.js:23

The issue is a regression from #6568 where I moved the version number from static get version() (always available) to be hardcoded in the defineCustomElement (only available for the first custom element definition).

The fix is to always define a version getter, regardless of whether the custom element is already defined or not.

Type of change

  • Bugfix

@web-padawan web-padawan changed the title fix: set custom element class version even if not defined fix: always define custom element class version getter Sep 18, 2024
Copy link

sonarcloud bot commented Sep 18, 2024

@@ -4,15 +4,15 @@
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/

export function defineCustomElement(CustomElement) {
export function defineCustomElement(CustomElement, version = '24.6.0-alpha0') {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note, I had to move version to an optional parameter because existing tests were using version object field thus making them false-positive (they should have been updated when refactoring logic in #6568).

I don't have better ideas how to mimic the actual case with two copies of the defineCustomElement loaded by the browser. At least with this logic, tests fail if Object.defineProperty is moved back to where it was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants