SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.55k stars 266 forks source link

registerThemeProperties with empty default CSS throws an exception #1599

Closed codefactor closed 4 years ago

codefactor commented 4 years ago

Describe the bug I created a new Web Component lib, and by default this lib has no new CSS variables, it is more of a composite library which uses other web components internally (the SuccessFactors Header). There are no new colors that it need to define.

The issue only happens when you have a new library in which the "parameter-bundle.css" is empty or contains only empty :root {} style.

Basically the /dist/generated/themes/sap_fiori_3/parameter-bundle.css.js is empty - because there are no variables (yet).

To reproduce Steps to reproduce the behavior:

  1. Make your default sap_fiori_3/parameter-bundle.css for the library empty
  2. Start up the page
  3. See exception

Isolated example (not sure if this is needed)

Expected behavior If the defaultTheme is empty string, calling registerThemeProperties should work as expected. But currently the code inside fetchThemeProperties assumes that this is a bug and throws an exception.

Screenshots If applicable, add screenshots to help explain your problem.

Context

Affected components (if known)

Log output / Any errors in the console

Themes.js:68 Uncaught (in promise) Error: You have to import the @xweb/common-webcomponents/dist/Assets.js module to switch to additional themes
    at fetchThemeProperties (Themes.js:68)
    at getThemeProperties (Themes.js:57)
codefactor commented 4 years ago

I am able to work around by adding the following to the parameters-bundle.css

:root {
    --bizx-ignore: true;
}

This seems OK for now, but this would result in an unnecessary CSS3 variable and