From 014316431e848ff549352d1f5ba4e491219199a3 Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 19 Jul 2021 11:28:11 -0700 Subject: [PATCH] Migrate core/keyboard_nav/marker.js to goog.module --- core/keyboard_nav/marker.js | 21 ++++++++++++--------- tests/deps.js | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/keyboard_nav/marker.js b/core/keyboard_nav/marker.js index 555bf7c97..115a1f861 100644 --- a/core/keyboard_nav/marker.js +++ b/core/keyboard_nav/marker.js @@ -11,7 +11,8 @@ */ 'use strict'; -goog.provide('Blockly.Marker'); +goog.module('Blockly.Marker'); +goog.module.declareLegacyNamespace(); goog.require('Blockly.ASTNode'); @@ -23,7 +24,7 @@ goog.requireType('Blockly.blockRendering.MarkerSvg'); * This is used in keyboard navigation to save a location in the Blockly AST. * @constructor */ -Blockly.Marker = function() { +const Marker = function() { /** * The colour of the marker. * @type {?string} @@ -56,7 +57,7 @@ Blockly.Marker = function() { * @param {Blockly.blockRendering.MarkerSvg} drawer The object in charge of * drawing the marker. */ -Blockly.Marker.prototype.setDrawer = function(drawer) { +Marker.prototype.setDrawer = function(drawer) { this.drawer_ = drawer; }; @@ -65,7 +66,7 @@ Blockly.Marker.prototype.setDrawer = function(drawer) { * @return {Blockly.blockRendering.MarkerSvg} The object in charge of drawing * the marker. */ -Blockly.Marker.prototype.getDrawer = function() { +Marker.prototype.getDrawer = function() { return this.drawer_; }; @@ -74,7 +75,7 @@ Blockly.Marker.prototype.getDrawer = function() { * @return {Blockly.ASTNode} The current field, connection, or block the marker * is on. */ -Blockly.Marker.prototype.getCurNode = function() { +Marker.prototype.getCurNode = function() { return this.curNode_; }; @@ -84,7 +85,7 @@ Blockly.Marker.prototype.getCurNode = function() { * output or previous connection on a stack. * @param {Blockly.ASTNode} newNode The new location of the marker. */ -Blockly.Marker.prototype.setCurNode = function(newNode) { +Marker.prototype.setCurNode = function(newNode) { const oldNode = this.curNode_; this.curNode_ = newNode; if (this.drawer_) { @@ -96,7 +97,7 @@ Blockly.Marker.prototype.setCurNode = function(newNode) { * Redraw the current marker. * @package */ -Blockly.Marker.prototype.draw = function() { +Marker.prototype.draw = function() { if (this.drawer_) { this.drawer_.draw(this.curNode_, this.curNode_); } @@ -105,7 +106,7 @@ Blockly.Marker.prototype.draw = function() { /** * Hide the marker SVG. */ -Blockly.Marker.prototype.hide = function() { +Marker.prototype.hide = function() { if (this.drawer_) { this.drawer_.hide(); } @@ -114,8 +115,10 @@ Blockly.Marker.prototype.hide = function() { /** * Dispose of this marker. */ -Blockly.Marker.prototype.dispose = function() { +Marker.prototype.dispose = function() { if (this.getDrawer()) { this.getDrawer().dispose(); } }; + +exports = Marker; diff --git a/tests/deps.js b/tests/deps.js index 759caeae4..8d3102c14 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -105,7 +105,7 @@ goog.addDependency('../../core/internal_constants.js', ['Blockly.internalConstan goog.addDependency('../../core/keyboard_nav/ast_node.js', ['Blockly.ASTNode'], ['Blockly.connectionTypes', 'Blockly.utils.Coordinate'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/keyboard_nav/basic_cursor.js', ['Blockly.BasicCursor'], ['Blockly.ASTNode', 'Blockly.Cursor', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/keyboard_nav/cursor.js', ['Blockly.Cursor'], ['Blockly.ASTNode', 'Blockly.Marker', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/keyboard_nav/marker.js', ['Blockly.Marker'], ['Blockly.ASTNode']); +goog.addDependency('../../core/keyboard_nav/marker.js', ['Blockly.Marker'], ['Blockly.ASTNode'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/keyboard_nav/tab_navigate_cursor.js', ['Blockly.TabNavigateCursor'], ['Blockly.ASTNode', 'Blockly.BasicCursor', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/marker_manager.js', ['Blockly.MarkerManager'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/menu.js', ['Blockly.Menu'], ['Blockly.browserEvents', 'Blockly.utils.Coordinate', 'Blockly.utils.KeyCodes', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.style'], {'lang': 'es6', 'module': 'goog'});