Repository navigation
refactor: rename theme property to _theme, deprecate theme - #3529
Merged
Merged
Conversation
vursen
force-pushed
the
refactor/rename-theme-to-_theme
branch
from
March 9, 2022 07:17
542a811 to
bf655bc
Compare
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
vursen
force-pushed
the
refactor/rename-theme-to-_theme
branch
from
March 9, 2022 07:17
bf655bc to
776c78c
Compare
5 tasks done
vursen
marked this pull request as ready for review
March 9, 2022 12:38
theme property to _themetheme property to _theme, deprecate theme
tomivirkki
reviewed
Mar 9, 2022
tomivirkki
reviewed
Mar 10, 2022
7 tasks done
vursen
force-pushed
the
refactor/rename-theme-to-_theme
branch
from
March 10, 2022 15:10
3ad0b41 to
e9790a8
Compare
|
Kudos, SonarCloud Quality Gate passed!
|
tomivirkki
approved these changes
Mar 11, 2022
web-padawan
approved these changes
Mar 11, 2022
7 tasks done
Collaborator
|
This ticket/PR has been released with Vaadin 23.1.0.alpha1 and is also targeting the upcoming stable 23.1.0 version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Description
The PR fixes the issue where it was not possible to set a theme for the web components in Svelte and Vue.
A little background, by design
ThemePropertyMixinallows specifying themes only via thethemeattribute. However, sinceThemePropertyMixinalso defines a protected read-only propertytheme, it makes both Svelte and Vue consider that thethemeattribute must be set via that property, which doesn't work because the property is read-only. In order to fix that, we need to rename thethemeproperty to something else so that it won't interfere with thethemeattribute and therefore Svelte and Vue will treat them separately and set the theme directly via the attribute as it is supposed to work. Based on the rule that every protected method should start with_, the correct naming will be_theme.themeproperty to_themeeverywhere it is used internally.themesetter and getter which are deprecated and will be dropped in Vaadin 24. They are simply a setter and getter for thethemeattribute. The deprecatedthemeproperty is supposed to be used by Svelte and Vue for the time being.Why no deprecation warning was added?
There was a discussion about whether to show a deprecation warning in the browser console on the first call of the
themesetter. The warning might be something like this:However, this warning may also pop up in the case a web component is used in Svelte or Vue. They implicitly set the
themeproperty instead of thethemeattribute and the warning will look very confusing as the user can't really fix the problem the warning is complaining about.What about Flow counterparts?
I didn't find any Flow counterpart manipulating the
themeproperty directly. They all appear to use thethemeattribute so everything should be okay in that regard.There is the
MenuBarcomponent though that has a private_themeproperty that can now possibly interfere with the web component's_themeproperty. Although IT tests are not failing, I would rather rename it to__themewhich is how we usually name private properties:https://github.com/vaadin/flow-components/blob/9615db2466baf55cb86c90f9e71aa294d47fd9df/vaadin-context-menu-flow-parent/vaadin-context-menu-flow/src/main/java/com/vaadin/flow/component/contextmenu/MenuItemBase.java#L50-L52
Fixes #3483
Type of change
Checklist