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

@@ -203,7 +203,7 @@ export class FieldDropdown extends Field {
}
if (this.borderRect_) {
dom.addClass(this.borderRect_, 'blocklyDropdownRect');
this.borderRect_.classList.add('blocklyDropdownRect');
}
}
@@ -275,7 +275,7 @@ export class FieldDropdown extends Field {
// Element gets created in render.
this.menu_!.render(dropDownDiv.getContentDiv());
const menuElement = this.menu_!.getElement() as Element;
dom.addClass(menuElement, 'blocklyDropdownMenu');
menuElement.classList.add('blocklyDropdownMenu');
if (this.getConstants()!.FIELD_DROPDOWN_COLOURED_DIV) {
const primaryColour = this.sourceBlock_.isShadow() ?
@@ -595,7 +595,7 @@ export class FieldDropdown extends Field {
private renderSelectedText_() {
// Retrieves the selected option to display through getText_.
this.textContent_.nodeValue = this.getDisplayText_();
dom.addClass(this.textElement_ as Element, 'blocklyDropdownText');
this.textElement_.classList.add('blocklyDropdownText');
this.textElement_.setAttribute('text-anchor', 'start');
// Height and width include the border rect.