diff --git a/core/components/component.js b/core/components/component.js index 0d985b7ef..cca8285d5 100644 --- a/core/components/component.js +++ b/core/components/component.js @@ -84,6 +84,13 @@ Blockly.Component = function() { * @private */ this.childIndex_ = {}; + + /** + * Whether or not the component has been disposed. + * @type {boolean} + * @private + */ + this.disposed_ = false; }; diff --git a/core/components/tree/basenode.js b/core/components/tree/basenode.js index 4416c6b6a..6e10d71b8 100644 --- a/core/components/tree/basenode.js +++ b/core/components/tree/basenode.js @@ -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); }; /** diff --git a/core/components/tree/treecontrol.js b/core/components/tree/treecontrol.js index 37f8dc779..97ea3e39d 100644 --- a/core/components/tree/treecontrol.js +++ b/core/components/tree/treecontrol.js @@ -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 ''; }; diff --git a/core/components/tree/treenode.js b/core/components/tree/treenode.js index 455e7b0f2..c6aa3f2d2 100644 --- a/core/components/tree/treenode.js +++ b/core/components/tree/treenode.js @@ -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); diff --git a/core/menu.js b/core/menu.js index 578b6cbf3..a1621e83b 100644 --- a/core/menu.js +++ b/core/menu.js @@ -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; }; diff --git a/core/menuitem.js b/core/menuitem.js index d483dcd45..ab93aec33 100644 --- a/core/menuitem.js +++ b/core/menuitem.js @@ -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}