From bc681677635f4fea31601ea3a371463c44360648 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 3 Oct 2019 19:39:06 -0700 Subject: [PATCH] Removed Object.assign() from turtle demo (#3157) * Removed Object.assign() from turtle demo. --- demos/custom-fields/turtle/blocks.js | 6 +++++- demos/custom-fields/turtle/field_turtle.js | 16 +++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/demos/custom-fields/turtle/blocks.js b/demos/custom-fields/turtle/blocks.js index b7766c5b7..ef8b245ae 100644 --- a/demos/custom-fields/turtle/blocks.js +++ b/demos/custom-fields/turtle/blocks.js @@ -48,7 +48,11 @@ Blockly.Blocks['turtle_nullifier'] = { }, validate: function(newValue) { - this.cachedValidatedValue_ = Object.assign({}, newValue); + this.cachedValidatedValue_ = { + turtleName: newValue.turtleName, + pattern: newValue.pattern, + hat: newValue.hat, + }; if ((newValue.turtleName == 'Leonardo' && newValue.hat == 'Mask') || (newValue.turtleName == 'Yertle' && newValue.hat == 'Crown') || (newValue.turtleName == 'Franklin') && newValue.hat == 'Propeller') { diff --git a/demos/custom-fields/turtle/field_turtle.js b/demos/custom-fields/turtle/field_turtle.js index 3cff025f6..8a4a08301 100644 --- a/demos/custom-fields/turtle/field_turtle.js +++ b/demos/custom-fields/turtle/field_turtle.js @@ -316,16 +316,18 @@ CustomFields.FieldTurtle.prototype.renderEditor_ = function() { // included inside render_ (it is not called anywhere else), but it is // usually separated to keep code more organized. CustomFields.FieldTurtle.prototype.updateSize_ = function() { - var size = this.movableGroup_.getBBox(); + var bbox = this.movableGroup_.getBBox(); + var width = bbox.width; + var height = bbox.height; if (this.borderRect_) { - size.width += this.PADDING; - size.height += this.PADDING; - this.borderRect_.setAttribute('width', size.width); - this.borderRect_.setAttribute('height', size.height); + width += this.PADDING; + height += this.PADDING; + this.borderRect_.setAttribute('width', width); + this.borderRect_.setAttribute('height', height); } // Note how both the width and the height can be dynamic. - this.size_.width = size.width; - this.size_.height = size.height; + this.size_.width = width; + this.size_.height = height; }; // Called when the field is clicked. It is usually used to show an editor,