diff --git a/core/block_svg.js b/core/block_svg.js index 79bfb942a..b781d61e6 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -503,23 +503,7 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) { * @param {boolean} forward If true go forward, otherwise backward. */ Blockly.BlockSvg.prototype.tab = function(start, forward) { - // This function need not be efficient since it runs once on a keypress. - // Create an ordered list of all text fields and connected inputs. - var list = []; - for (var i = 0, input; input = this.inputList[i]; i++) { - for (var j = 0, field; field = input.fieldRow[j]; j++) { - if (field instanceof Blockly.FieldTextInput) { - // TODO: Also support dropdown fields. - list.push(field); - } - } - if (input.connection) { - var block = input.connection.targetBlock(); - if (block) { - list.push(block); - } - } - } + var list = this.createTabList_(); var i = list.indexOf(start); if (i == -1) { // No start location, start at the beginning or end. @@ -539,6 +523,31 @@ Blockly.BlockSvg.prototype.tab = function(start, forward) { } }; +/** + * Create an ordered list of all text fields and connected inputs. + * @return {!Array} The ordered list. + * @private + */ +Blockly.BlockSvg.prototype.createTabList_ = function() { + // This function need not be efficient since it runs once on a keypress. + var list = []; + for (var i = 0, input; input = this.inputList[i]; i++) { + for (var j = 0, field; field = input.fieldRow[j]; j++) { + if (field instanceof Blockly.FieldTextInput) { + // TODO(# 1276): Also support dropdown fields. + list.push(field); + } + } + if (input.connection) { + var block = input.connection.targetBlock(); + if (block) { + list.push(block); + } + } + } + return list; +}; + /** * Handle a mouse-down on an SVG block. * @param {!Event} e Mouse down event or touch start event.