fix: remove calls to removeClass and hasClass (#6413)

* fix: stop using dom.addClass in most cases

* chore: format

* fix: remove use of dom.addClass in toolbox

* chore: lint and format

* fix: add checks around non-constant class names

* fix: switch back to quoted access

* chore: format

* fix: remove calls to removeClass

* chore: format

* chore: remove unused deps

* fix: remove uses of hasClass

* chore: format and lint

* chore: format
This commit is contained in:
Rachel Fenichel
2022-09-13 08:33:49 -07:00
committed by GitHub
parent 26561947fb
commit 5f11f3449f
26 changed files with 164 additions and 145 deletions

View File

@@ -15,7 +15,6 @@ goog.declareModuleId('Blockly.ThemeManager');
import type {Theme} from './theme.js';
import * as arrayUtils from './utils/array.js';
import * as dom from './utils/dom.js';
import type {Workspace} from './workspace.js';
import type {WorkspaceSvg} from './workspace_svg.js';
@@ -61,9 +60,15 @@ export class ThemeManager {
const injectionDiv = this.workspace.getInjectionDiv();
if (injectionDiv) {
if (prevTheme) {
dom.removeClass(injectionDiv, prevTheme.getClassName());
const oldClassName = prevTheme.getClassName();
if (oldClassName) {
injectionDiv.classList.remove(oldClassName);
}
}
const newClassName = this.theme.getClassName();
if (newClassName) {
injectionDiv.classList.add(newClassName);
}
dom.addClass(injectionDiv, this.theme.getClassName());
}
// Refresh all subscribed workspaces.