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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
!
will eventually happen to be undefined, and we are back in the scenario where an exception is thrown and no theme is loaded. Can we provide a better fallback?Also, this was the case before, but what if a custom theme has a
.
in the name? is it escaped? should we also check this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom themes can't have a
.
in the theme name, otherwise they couldn't even be saved by the theming engine.Starting with SAP/theming-base-content@11.23.0, there is
--sapSapThemeId
, which might be a good fallback (is always an SAP theme, but that might be what you're after anyways):Maybe you don't even need JavaScript for that anymore, because you can target
--sapSapThemeId
with CSS container style queries – see Theme-specific CSS for your application.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the insight!
I changed the check a bit - if there are 4 parts (after splitting) then this means we're with the "known" format and themeId is guaranteed to be the third part.
However, if this is not the case (future versions of the metadata), we read the CSS var as this is the standard as of last release.