From f76a407027d98e9a88de7fa4cc27cb60cf250489 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 6 Mar 2019 08:02:09 -0800 Subject: [PATCH] various typing fixes --- fieldeditors/field_brickbuttons.ts | 9 +++++---- fieldeditors/field_motors.ts | 31 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/fieldeditors/field_brickbuttons.ts b/fieldeditors/field_brickbuttons.ts index f55ed62b..c9e7a2ad 100644 --- a/fieldeditors/field_brickbuttons.ts +++ b/fieldeditors/field_brickbuttons.ts @@ -152,9 +152,10 @@ export class FieldBrickButtons extends Blockly.FieldDropdown implements Blockly. * Callback for when the drop-down is hidden. */ private onHide_ = function () { - Blockly.DropDownDiv.content_.removeAttribute('role'); - Blockly.DropDownDiv.content_.removeAttribute('aria-haspopup'); - Blockly.DropDownDiv.content_.removeAttribute('aria-activedescendant'); - Blockly.DropDownDiv.getContentDiv().style.width = ''; + const content = Blockly.DropDownDiv.getContentDiv(); + content.removeAttribute('role'); + content.removeAttribute('aria-haspopup'); + content.removeAttribute('aria-activedescendant'); + content.style.width = ''; }; } \ No newline at end of file diff --git a/fieldeditors/field_motors.ts b/fieldeditors/field_motors.ts index a9212afd..e04e7b15 100644 --- a/fieldeditors/field_motors.ts +++ b/fieldeditors/field_motors.ts @@ -53,7 +53,7 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC this.arrow_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', (Blockly.FieldDropdown as any).DROPDOWN_SVG_DATAURI); - this.arrow2_ = Blockly.utils.createSvgElement('image', { + this.arrow2_ = Blockly.utils.createSvgElement('image', { 'height': (this as any).arrowSize_ + 'px', 'width': (this as any).arrowSize_ + 'px' }); @@ -79,7 +79,7 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC }, this.fieldGroup_); fieldX += 10; // size of first group. - this.textElement2_ = Blockly.utils.createSvgElement('text', + this.textElement2_ = Blockly.utils.createSvgElement('text', { 'class': (this as any).className_, 'x': fieldX, @@ -89,7 +89,7 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC this.fieldGroup_); this.updateEditable(); - this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_); + (this.sourceBlock_ as Blockly.BlockSvg).getSvgRoot().appendChild(this.fieldGroup_); // Force a render. this.render_(); this.size_.width = 0; @@ -99,7 +99,7 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC // Add second dropdown if (this.shouldShowRect_()) { - this.box_ = Blockly.utils.createSvgElement('rect', { + this.box_ = Blockly.utils.createSvgElement('rect', { 'rx': (Blockly.BlockSvg as any).CORNER_RADIUS, 'ry': (Blockly.BlockSvg as any).CORNER_RADIUS, 'x': 0, @@ -112,7 +112,7 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC 'fill-opacity': 1 }, null); this.fieldGroup_.insertBefore(this.box_, this.textElement_); - this.box2_ = Blockly.utils.createSvgElement('rect', { + this.box2_ = Blockly.utils.createSvgElement('rect', { 'rx': (Blockly.BlockSvg as any).CORNER_RADIUS, 'ry': (Blockly.BlockSvg as any).CORNER_RADIUS, 'x': 0, @@ -233,8 +233,8 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC if (this.textElement2_) { this.textElement2_.parentNode.appendChild(this.arrow2_); } - if (this.sourceBlock_ && this.sourceBlock_.rendered) { - this.sourceBlock_.render(); + if (this.sourceBlock_ && (this.sourceBlock_).rendered) { + (this.sourceBlock_).render(); this.sourceBlock_.bumpNeighbours_(); } } @@ -311,12 +311,12 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC // First dropdown // Use one of the following options, medium motor, large motor or large motors (translated) - const textNode1 = document.createTextNode(this.getFirstValueI11n(this.value_)); + const textNode1 = document.createTextNode(this.getFirstValueI11n(this.value_)); this.textElement_.appendChild(textNode1); // Second dropdown, no need to translate. Only port numbers if (this.textElement2_) { - const textNode2 = document.createTextNode(this.getSecondValue(this.value_)); + const textNode2 = document.createTextNode(this.getSecondValue(this.value_)); this.textElement2_.appendChild(textNode2); } this.updateWidth(); @@ -433,8 +433,8 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC vals[text] = value; } - const currentFirst = this.getFirstValue(this.value_); - const currentSecond = this.getSecondValue(this.value_); + const currentFirst = this.getFirstValue(this.value_); + const currentSecond = this.getSecondValue(this.value_); if (!this.isFirst_) { options = opts[currentFirst]; @@ -561,10 +561,11 @@ export class FieldMotors extends Blockly.FieldDropdown implements Blockly.FieldC * Callback for when the drop-down is hidden. */ protected onHide_() { - Blockly.DropDownDiv.content_.removeAttribute('role'); - Blockly.DropDownDiv.content_.removeAttribute('aria-haspopup'); - Blockly.DropDownDiv.content_.removeAttribute('aria-activedescendant'); - Blockly.DropDownDiv.getContentDiv().style.width = ''; + const content = Blockly.DropDownDiv.getContentDiv(); + content.removeAttribute('role'); + content.removeAttribute('aria-haspopup'); + content.removeAttribute('aria-activedescendant'); + content.style.width = ''; if (this.isFirst_ && this.box_) { this.box_.setAttribute('fill', this.sourceBlock_.getColour()); } else if (!this.isFirst_ && this.box2_) {