setTheme does not load theme if `themePath` was not specified in the configuration
DmitryEfimenko opened this issue · comments
Reproduction
Steps to reproduce:
- Open this StackBlitz link
- Observe that theme was not applied because themePath was not provided in the config.
Expected Behavior
What behavior were you expecting to see?
Theme should be loaded. I think specifying themePath
in the configuration should be optional.
The application might have conditional logic for loading theme based on user preferences. There's no need to first load a theme that the user does not need, and then switch to a user-preferred theme.
Actual Behavior
What behavior did you actually see?
Theme is not loaded due to an error.
StackBlitz doesn't provide a good error stack trace. Here's what I get locally:
ERROR TypeError: Cannot set properties of undefined (setting 'href')
at HighlightLoader.setTheme (ngx-highlightjs.mjs:133:36)
This points to this line of code
The _themeLinkElement
is undefined because loadTheme
, which sets this variable, never got to run
Environment
- Angular: 15
- ngx-highlightjs: ^7.0.1
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
Thanks for reporting! here is a fixed stackblitz with v8.0.0