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: prevent runtime error on malformed custom theme object #4375

Merged
merged 4 commits into from
Nov 23, 2021

Conversation

vladitasev
Copy link
Contributor

@vladitasev vladitasev commented Nov 22, 2021

Changes:

  • When a custom theme is detected, and the Path property of its metadata object is malformed, applyTheme.js ends up calling createOrUpdateStyle with undefined as the first parameter.

This failed silently before, as cssText could be a string only. After the recent CSP-related changes, cssText can be either a string, or an object. To better reflect this change, the cssText variable has been renamed to cssData.

  • Each error (of possible 3) is reported only once during custom theme detection

  • Most notably, when detecting a custom theme, each of the meta-classes is applied consecutively and tested for. This allows to test for sapThemeMetaData-Base-baseLib first, and only if not found, to look for sapThemeMetaData-UI5-sap-ui-core. This preserves the old behavior.

fixes: #4346

Copy link
Collaborator

@MarcusNotheis MarcusNotheis left a comment

Choose a reason for hiding this comment

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

This change prevents the error, but it's still flooding the console with warnings (497 warnings):
image

@vladitasev
Copy link
Contributor Author

@MarcusNotheis

I did some more fixes - the errors are reported only once, but this is no longer necessary for your use case. See the 3rd point in the changes list in the PR

Copy link
Collaborator

@MarcusNotheis MarcusNotheis left a comment

Choose a reason for hiding this comment

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

Works perfectly fine, thanks @vladitasev!

@vladitasev vladitasev merged commit 3215c7d into master Nov 23, 2021
@vladitasev vladitasev deleted the theming-error-fix branch November 23, 2021 07:31
ndeshev pushed a commit to ndeshev/ui5-webcomponents that referenced this pull request Dec 13, 2021
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.

Custom Themes via Theme Designer is unstable/broken
3 participants