schizophrenicmaniac opened a new pull request, #21781:
URL: https://github.com/apache/echarts/pull/21781

   <!-- Please fill in the following information to help us review your PR more 
efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Makes `setTheme(undefined | null)` go back to the default theme and logs a 
dev warning when `setTheme` gets a theme name that isn't registered.
   
   ### Fixed issues
   
   - #21779: setTheme() with no theme, null or an unregistered name silently 
keeps the current theme
   
   ## Details
   
   ### Before: What was the problem?
   
   `_updateTheme` only assigned `this._theme` when the argument resolved to a 
truthy theme. So `setTheme(undefined)`, `setTheme(null)` and 
`setTheme('<unregistered name>')` all left the previous theme in place with no 
warning. That meant a chart started with `'dark'` couldn't go back to the 
default theme this way, even though `init(dom, undefined)` means "default 
theme".
   
   ### After: How does it behave after the fixing?
   
   `null`/`undefined` now resets the theme to the default (`{}`), the same as 
`init` without a theme. An unregistered name logs `Theme xxx is not 
registered.` in dev mode and keeps the current theme, the same way other 
invalid arguments are handled (e.g. `showLoading` with an unknown effect). 
Registered names and theme objects work as before.
   
   I added unit tests in `test/ut/spec/api/setTheme.test.ts` for all three 
cases.
   
   ## Document Info
   
   One of the following should be checked.
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   ## Misc
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   <!-- PLEASE CHECK IT AGAINST: 
<https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors>
 -->
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   `test/ut/spec/api/setTheme.test.ts`
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information
   
   Fixes #21779


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to