Cleanup types under components/ (#3910)

* Fix types under components

* Fix menu
This commit is contained in:
Sam El-Husseini
2020-05-20 16:54:53 -07:00
committed by GitHub
parent 6809f63555
commit 3f4faeab46
6 changed files with 50 additions and 11 deletions

View File

@@ -84,6 +84,13 @@ Blockly.Component = function() {
* @private
*/
this.childIndex_ = {};
/**
* Whether or not the component has been disposed.
* @type {boolean}
* @private
*/
this.disposed_ = false;
};

View File

@@ -114,7 +114,7 @@ Blockly.utils.object.inherits(Blockly.tree.BaseNode, Blockly.Component);
* cssExpandedFolderIcon:string,
* cssCollapsedFolderIcon:string,
* cssFileIcon:string,
* cssSelectedRow:string
* cssSelectedRow:string,
* }}
*/
Blockly.tree.BaseNode.Config;
@@ -193,7 +193,7 @@ Blockly.tree.BaseNode.prototype.initAccessibility = function() {
Blockly.tree.BaseNode.prototype.createDom = function() {
var element = document.createElement('div');
element.appendChild(this.toDom());
this.setElementInternal(/** @type {!Element} */ (element));
this.setElementInternal(/** @type {!HTMLElement} */ (element));
};
@@ -368,6 +368,16 @@ Blockly.tree.BaseNode.prototype.getChildren = function() {
return children;
};
/**
* Returns the node's parent, if any.
* @return {?Blockly.tree.BaseNode} The parent node.
* @protected
*/
Blockly.tree.BaseNode.prototype.getParent = function() {
return /** @type {Blockly.tree.BaseNode} */ (
Blockly.tree.BaseNode.superClass_.getParent.call(this));
};
/**
* @return {Blockly.tree.BaseNode} The previous sibling of this node.
* @protected
@@ -622,7 +632,7 @@ Blockly.tree.BaseNode.prototype.getBackgroundPosition = function() {
};
/**
* @return {Element} The element for the tree node.
* @return {HTMLElement} The element for the tree node.
* @override
*/
Blockly.tree.BaseNode.prototype.getElement = function() {
@@ -631,7 +641,7 @@ Blockly.tree.BaseNode.prototype.getElement = function() {
el = document.getElementById(this.getId());
this.setElementInternal(el);
}
return el;
return /** @type {!HTMLElement} */ (el);
};
/**

View File

@@ -59,6 +59,20 @@ Blockly.tree.TreeControl = function(toolbox, config) {
* @private
*/
this.selectedItem_ = this;
/**
* A handler that's triggered before a node is selected.
* @type {?function(Blockly.tree.BaseNode):boolean}
* @private
*/
this.onBeforeSelected_ = null;
/**
* A handler that's triggered before a node is selected.
* @type {?function(Blockly.tree.BaseNode, Blockly.tree.BaseNode):?}
* @private
*/
this.onAfterSelected_ = null;
};
Blockly.utils.object.inherits(Blockly.tree.TreeControl, Blockly.tree.BaseNode);
@@ -123,11 +137,6 @@ Blockly.tree.TreeControl.prototype.getCalculatedIconClass = function() {
if (!expanded && iconClass) {
return iconClass;
}
// fall back on default icons
if (expanded && this.config_.cssExpandedRootIcon) {
return this.config_.cssTreeIcon + ' ' + this.config_.cssExpandedRootIcon;
}
return '';
};

View File

@@ -32,6 +32,13 @@ goog.require('Blockly.utils.KeyCodes');
Blockly.tree.TreeNode = function(toolbox, content, config) {
this.toolbox_ = toolbox;
Blockly.tree.BaseNode.call(this, content, config);
/**
* A handler that's triggered when the size of node has changed.
* @type {?function():?}
* @private
*/
this.onSizeChanged_ = null;
};
Blockly.utils.object.inherits(Blockly.tree.TreeNode, Blockly.tree.BaseNode);

View File

@@ -114,7 +114,7 @@ Blockly.Menu.prototype.addChild = function(menuItem) {
* @param {!Element} container Element upon which to append this menu.
*/
Blockly.Menu.prototype.render = function(container) {
var element = document.createElement('div');
var element = /** @type {!HTMLDivElement} */ (document.createElement('div'));
// goog-menu is deprecated, use blocklyMenu. May 2020.
element.className = 'blocklyMenu goog-menu blocklyNonSelectable';
element.tabIndex = 0;
@@ -215,7 +215,6 @@ Blockly.Menu.prototype.dispose = function() {
for (var i = 0, menuItem; (menuItem = this.menuItems_[i]); i++) {
menuItem.dispose();
}
this.menuItems_length = 0;
this.element_ = null;
};

View File

@@ -82,6 +82,13 @@ Blockly.MenuItem = function(content, opt_value) {
*/
this.checked_ = false;
/**
* Is this menu item currently highlighted.
* @type {boolean}
* @private
*/
this.highlight_ = false;
/**
* Bound function to call when this menu item is clicked.
* @type {Function}