diff --git a/core/block_svg.js b/core/block_svg.js index e8626e9ae..4d9032e5f 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -262,6 +262,7 @@ Blockly.BlockSvg.prototype.getIcons = function() { /** * Set parent of this block to be a new block or null. * @param {Blockly.BlockSvg} newParent New parent block. + * @override */ Blockly.BlockSvg.prototype.setParent = function(newParent) { var oldParent = this.parentBlock_; @@ -894,10 +895,10 @@ Blockly.BlockSvg.prototype.getSvgRoot = function() { /** * Dispose of this block. - * @param {boolean} healStack If true, then try to heal any gap by connecting + * @param {boolean=} healStack If true, then try to heal any gap by connecting * the next statement with the previous statement. Otherwise, dispose of * all children of this block. - * @param {boolean} animate If true, show a disposal animation and sound. + * @param {boolean=} animate If true, show a disposal animation and sound. */ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { if (!this.workspace) { diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 62e310794..426bdab04 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -199,7 +199,7 @@ Blockly.DropDownDiv.setCategory = function(category) { * @param {!Blockly.Block} block Block to position the drop-down around. * @param {Function=} opt_onHide Optional callback for when the drop-down is * hidden. - * @param {number} opt_secondaryYOffset Optional Y offset for above-block + * @param {number=} opt_secondaryYOffset Optional Y offset for above-block * positioning. * @return {boolean} True if the menu rendered below block; false if above. */ diff --git a/core/field.js b/core/field.js index 7d45ca4a4..ffc903d82 100644 --- a/core/field.js +++ b/core/field.js @@ -887,7 +887,7 @@ Blockly.Field.prototype.onMouseDown_ = function(e) { /** * Change the tooltip text for this field. - * @param {string|function|!Element} newTip Text for tooltip or a parent + * @param {string|Function|!Element} newTip Text for tooltip or a parent * element to link to for its tooltip. */ Blockly.Field.prototype.setTooltip = function(newTip) { diff --git a/core/field_angle.js b/core/field_angle.js index 75e65fb62..842eaf081 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -337,6 +337,7 @@ Blockly.FieldAngle.prototype.updateGraph_ = function() { * @param {string|number=} newValue The input value. * @return {?number} A valid angle, or null if invalid. * @protected + * @override */ Blockly.FieldAngle.prototype.doClassValidation_ = function(newValue) { if (isNaN(newValue)) { diff --git a/core/field_image.js b/core/field_image.js index 23737e15f..fc8a21fa8 100644 --- a/core/field_image.js +++ b/core/field_image.js @@ -36,7 +36,7 @@ goog.require('goog.math.Size'); /** * Class for an image on a block. - * @param {string=} src The URL of the image. Defaults to an empty string. + * @param {string} src The URL of the image. Defaults to an empty string. * @param {!(string|number)} width Width of the image. * @param {!(string|number)} height Height of the image. * @param {string=} opt_alt Optional alt text for when block is collapsed. @@ -50,6 +50,9 @@ Blockly.FieldImage = function(src, width, height, opt_alt, opt_onClick, opt_flipRtl) { this.sourceBlock_ = null; + if (!src) { + throw Error('Src value of an image field is required'); + } if (isNaN(height) || isNaN(width)) { throw Error('Height and width values of an image field must cast to' + diff --git a/core/field_number.js b/core/field_number.js index 2e729d193..807158077 100644 --- a/core/field_number.js +++ b/core/field_number.js @@ -39,6 +39,7 @@ goog.require('Blockly.FieldTextInput'); * @param {Function=} opt_validator A function that is called to validate * changes to the field's value. Takes in a number & returns a validated * number, or null to abort the change. + * @extends {Blockly.FieldTextInput} * @constructor */ Blockly.FieldNumber = function(opt_value, opt_min, opt_max, opt_precision, @@ -105,6 +106,7 @@ Blockly.FieldNumber.prototype.setConstraints = function(min, max, precision) { * @param {string|number=} newValue The input value. * @return {?number} A valid number, or null if invalid. * @protected + * @override */ Blockly.FieldNumber.prototype.doClassValidation_ = function(newValue) { if (newValue === null || newValue === undefined) { diff --git a/core/rendered_connection.js b/core/rendered_connection.js index 1a4ae30fa..586dfaac6 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -320,7 +320,7 @@ Blockly.RenderedConnection.prototype.hideAll = function() { /** * Check if the two connections can be dragged to connect to each other. * @param {!Blockly.Connection} candidate A nearby connection to check. - * @param {number} maxRadius The maximum radius allowed for connections, in + * @param {number=} maxRadius The maximum radius allowed for connections, in * workspace units. * @return {boolean} True if the connection is allowed, false otherwise. */ diff --git a/core/theme.js b/core/theme.js index cda37fd5b..acca71a4a 100644 --- a/core/theme.js +++ b/core/theme.js @@ -27,16 +27,29 @@ goog.provide('Blockly.Theme'); /** - * A block style or a category style. - * @typedef {!Object.} - */ -Blockly.Theme.Style; + * A block style. + * @typedef {{ + * colourPrimary:string, + * colourSecondary:string, + * colourTertiary:string, + * hat:string + * }} + */ +Blockly.Theme.BlockStyle; + +/** + * A category style. + * @typedef {{ + * colour:string + * }} + */ +Blockly.Theme.CategoryStyle; /** * Class for a theme. - * @param {!Object.} blockStyles A map from style + * @param {!Object.} blockStyles A map from style * names (strings) to objects with style attributes relating to blocks. - * @param {!Object.} categoryStyles A map from + * @param {!Object.} categoryStyles A map from * style names (strings) to objects with style attributes relating to * categories. * @constructor @@ -48,7 +61,7 @@ Blockly.Theme = function(blockStyles, categoryStyles) { /** * Overrides or adds all values from blockStyles to blockStyles_ - * @param {Object.} blockStyles Map of + * @param {Object.} blockStyles Map of * block styles. */ Blockly.Theme.prototype.setAllBlockStyles = function(blockStyles) { @@ -59,7 +72,7 @@ Blockly.Theme.prototype.setAllBlockStyles = function(blockStyles) { /** * Gets a map of all the block style names. - * @return {!Object.} Map of block styles. + * @return {!Object.} Map of block styles. */ Blockly.Theme.prototype.getAllBlockStyles = function() { return this.blockStyles_; @@ -68,7 +81,7 @@ Blockly.Theme.prototype.getAllBlockStyles = function() { /** * Gets the BlockStyle for the given block style name. * @param {string} blockStyleName The name of the block style. - * @return {Blockly.Theme.Style|undefined} The named block style. + * @return {Blockly.Theme.BlockStyle|undefined} The named block style. */ Blockly.Theme.prototype.getBlockStyle = function(blockStyleName) { return this.blockStyles_[blockStyleName]; @@ -77,7 +90,7 @@ Blockly.Theme.prototype.getBlockStyle = function(blockStyleName) { /** * Overrides or adds a style to the blockStyles map. * @param {string} blockStyleName The name of the block style. - * @param {Blockly.Theme.Style} blockStyle The block style. + * @param {Blockly.Theme.BlockStyle} blockStyle The block style. */ Blockly.Theme.prototype.setBlockStyle = function(blockStyleName, blockStyle) { this.blockStyles_[blockStyleName] = blockStyle; @@ -86,7 +99,7 @@ Blockly.Theme.prototype.setBlockStyle = function(blockStyleName, blockStyle) { /** * Gets the CategoryStyle for the given category style name. * @param {string} categoryStyleName The name of the category style. - * @return {Blockly.Theme.Style|undefined} The named category style. + * @return {Blockly.Theme.CategoryStyle|undefined} The named category style. */ Blockly.Theme.prototype.getCategoryStyle = function(categoryStyleName) { return this.categoryStyles_[categoryStyleName]; @@ -95,7 +108,7 @@ Blockly.Theme.prototype.getCategoryStyle = function(categoryStyleName) { /** * Overrides or adds a style to the categoryStyles map. * @param {string} categoryStyleName The name of the category style. - * @param {Blockly.Theme.Style} categoryStyle The category style. + * @param {Blockly.Theme.CategoryStyle} categoryStyle The category style. */ Blockly.Theme.prototype.setCategoryStyle = function(categoryStyleName, categoryStyle) { diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 2b3f3ef52..e3653b5fc 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -671,6 +671,7 @@ Blockly.WorkspaceSvg.prototype.dispose = function() { * @param {string=} opt_id Optional ID. Use this ID if provided, otherwise * create a new ID. * @return {!Blockly.BlockSvg} The created block. + * @override */ Blockly.WorkspaceSvg.prototype.newBlock = function(prototypeName, opt_id) { return new Blockly.BlockSvg(this, prototypeName, opt_id); diff --git a/tests/mocha/field_image_test.js b/tests/mocha/field_image_test.js index ca39f0c22..c175d3dda 100644 --- a/tests/mocha/field_image_test.js +++ b/tests/mocha/field_image_test.js @@ -25,9 +25,6 @@ suite ('Image Fields', function() { assertEquals(actualValue, expectedValue); assertEquals(actualText, expectedText); } - function assertValueDefault(imageField) { - assertValue(imageField, '', ''); - } suite('Constructor', function() { test('Empty', function() { chai.assert.throws(function() { @@ -35,12 +32,14 @@ suite ('Image Fields', function() { }); }); test('Null Src', function() { - var imageField = new Blockly.FieldImage(null, 1, 1); - assertValueDefault(imageField); + chai.assert.throws(function() { + new Blockly.FieldImage(null, 1, 1); + }); }); test('Undefined Src', function() { - var imageField = new Blockly.FieldImage(undefined, 1, 1); - assertValueDefault(imageField); + chai.assert.throws(function() { + new Blockly.FieldImage(undefined, 1, 1); + }); }); test('Null Size', function() { chai.assert.throws(function() { @@ -81,20 +80,22 @@ suite ('Image Fields', function() { }); }); test('Null Src', function() { - var imageField = Blockly.FieldImage.fromJson({ - src: null, - width: 1, - height: 1 + chai.assert.throws(function() { + Blockly.FieldImage.fromJson({ + src: null, + width: 1, + height: 1 + }); }); - assertValueDefault(imageField); }); test('Undefined Src', function() { - var imageField = Blockly.FieldImage.fromJson({ - src: undefined, - width: 1, - height: 1 + chai.assert.throws(function() { + Blockly.FieldImage.fromJson({ + src: undefined, + width: 1, + height: 1 + }); }); - assertValueDefault(imageField); }); test('Null Size', function() { chai.assert.throws(function() {