From c51cf0b79cd19d7d4dd6cd1a6dd5879d6773ae9f Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Fri, 29 Jun 2018 15:58:41 -0700 Subject: [PATCH] Remove goog.dom.removeNode --- core/block_animations.js | 6 ++---- core/block_svg.js | 3 +-- core/bubble.js | 3 +-- core/field.js | 7 ++++--- core/field_dropdown.js | 7 ++++--- core/field_image.js | 7 ++++--- core/field_label.js | 7 ++++--- core/flyout_base.js | 5 ++--- core/flyout_button.js | 3 +-- core/icon.js | 3 +-- core/rendered_connection.js | 3 +-- core/scrollbar.js | 5 ++--- core/toolbox.js | 2 +- core/trashcan.js | 3 +-- core/variables_dynamic.js | 2 ++ core/workspace_comment_svg.js | 2 +- core/workspace_svg.js | 2 +- core/xml.js | 4 ++-- core/zoom_controls.js | 4 +--- 19 files changed, 36 insertions(+), 42 deletions(-) diff --git a/core/block_animations.js b/core/block_animations.js index 3ec7a575a..3d35dfee1 100644 --- a/core/block_animations.js +++ b/core/block_animations.js @@ -28,8 +28,6 @@ goog.provide('Blockly.BlockAnimations'); goog.require('Blockly.utils'); -goog.require('goog.dom'); - /** * PID of disconnect UI animation. There can only be one at a time. @@ -83,7 +81,7 @@ Blockly.BlockAnimations.disposeUiStep_ = function(clone, rtl, start, var ms = new Date - start; var percent = ms / 150; if (percent > 1) { - goog.dom.removeNode(clone); + clone.parentNode.removeChild(clone); } else { var x = clone.translateX_ + (rtl ? -1 : 1) * clone.bBox_.width * workspaceScale / 2 * percent; @@ -143,7 +141,7 @@ Blockly.BlockAnimations.connectionUiStep_ = function(ripple, start, scale) { var ms = new Date - start; var percent = ms / 150; if (percent > 1) { - goog.dom.removeNode(ripple); + ripple.parentNode.removeChild(ripple); } else { ripple.setAttribute('r', percent * 25 * scale); ripple.style.opacity = 1 - percent; diff --git a/core/block_svg.js b/core/block_svg.js index fbf9ea947..526787c06 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -38,7 +38,6 @@ goog.require('Blockly.Touch'); goog.require('Blockly.utils'); goog.require('goog.color'); -goog.require('goog.dom'); goog.require('goog.math.Coordinate'); @@ -849,7 +848,7 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { } Blockly.BlockSvg.superClass_.dispose.call(this, healStack); - goog.dom.removeNode(this.svgGroup_); + this.svgGroup_.parentNode.removeChild(this.svgGroup_); blockWorkspace.resizeContents(); // Sever JavaScript to DOM connections. this.svgGroup_ = null; diff --git a/core/bubble.js b/core/bubble.js index 66d5b68e8..f0cc1182f 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -28,7 +28,6 @@ goog.provide('Blockly.Bubble'); goog.require('Blockly.Touch'); goog.require('Blockly.Workspace'); -goog.require('goog.dom'); goog.require('goog.math.Coordinate'); goog.require('goog.userAgent'); @@ -605,7 +604,7 @@ Blockly.Bubble.prototype.setColour = function(hexColour) { Blockly.Bubble.prototype.dispose = function() { Blockly.Bubble.unbindDragEvents_(); // Dispose of and unlink the bubble. - goog.dom.removeNode(this.bubbleGroup_); + this.bubbleGroup_.parentNode.removeChild(this.bubbleGroup_); this.bubbleGroup_ = null; this.bubbleArrow_ = null; this.bubbleBack_ = null; diff --git a/core/field.js b/core/field.js index bd9f46246..a3123e38c 100644 --- a/core/field.js +++ b/core/field.js @@ -32,7 +32,6 @@ goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Gesture'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.math.Size'); goog.require('goog.style'); goog.require('goog.userAgent'); @@ -228,8 +227,10 @@ Blockly.Field.prototype.dispose = function() { this.mouseDownWrapper_ = null; } this.sourceBlock_ = null; - goog.dom.removeNode(this.fieldGroup_); - this.fieldGroup_ = null; + if (this.fieldGroup_) { + this.fieldGroup_.parentNode.removeChild(this.fieldGroup_); + this.fieldGroup_ = null; + } this.textElement_ = null; this.borderRect_ = null; this.validator_ = null; diff --git a/core/field_dropdown.js b/core/field_dropdown.js index ceddf39a9..b7ca8fdc0 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -32,7 +32,6 @@ goog.require('Blockly.Field'); goog.require('Blockly.utils'); goog.require('Blockly.utils.uiMenu'); -goog.require('goog.dom'); goog.require('goog.events'); goog.require('goog.ui.Menu'); goog.require('goog.ui.MenuItem'); @@ -441,8 +440,10 @@ Blockly.FieldDropdown.prototype.render_ = function() { while ((child = this.textElement_.firstChild)) { this.textElement_.removeChild(child); } - goog.dom.removeNode(this.imageElement_); - this.imageElement_ = null; + if (this.imageElement_) { + this.imageElement_.parentNode.removeChild(this.imageElement_); + this.imageElement_ = null; + } if (this.imageJson_) { this.renderSelectedImage_(); diff --git a/core/field_image.js b/core/field_image.js index 6027b14c4..f6d0c534f 100644 --- a/core/field_image.js +++ b/core/field_image.js @@ -29,7 +29,6 @@ goog.provide('Blockly.FieldImage'); goog.require('Blockly.Field'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.math.Size'); @@ -120,8 +119,10 @@ Blockly.FieldImage.prototype.init = function() { * Dispose of all DOM objects belonging to this text. */ Blockly.FieldImage.prototype.dispose = function() { - goog.dom.removeNode(this.fieldGroup_); - this.fieldGroup_ = null; + if (this.fieldGroup_) { + this.fieldGroup_.parentNode.removeChild(this.fieldGroup_); + this.fieldGroup_ = null; + } this.imageElement_ = null; }; diff --git a/core/field_label.js b/core/field_label.js index ca195b3af..c473d2be5 100644 --- a/core/field_label.js +++ b/core/field_label.js @@ -30,7 +30,6 @@ goog.require('Blockly.Field'); goog.require('Blockly.Tooltip'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.math.Size'); @@ -96,8 +95,10 @@ Blockly.FieldLabel.prototype.init = function() { * Dispose of all DOM objects belonging to this text. */ Blockly.FieldLabel.prototype.dispose = function() { - goog.dom.removeNode(this.textElement_); - this.textElement_ = null; + if (this.textElement_) { + this.textElement_.parentNode.removeChild(this.textElement_); + this.textElement_ = null; + } }; /** diff --git a/core/flyout_base.js b/core/flyout_base.js index 9cf01d43f..65b51ef4b 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -36,7 +36,6 @@ goog.require('Blockly.Touch'); goog.require('Blockly.utils'); goog.require('Blockly.WorkspaceSvg'); -goog.require('goog.dom'); goog.require('goog.math.Rect'); @@ -277,7 +276,7 @@ Blockly.Flyout.prototype.dispose = function() { this.workspace_ = null; } if (this.svgGroup_) { - goog.dom.removeNode(this.svgGroup_); + this.svgGroup_.parentNode.removeChild(this.svgGroup_); this.svgGroup_ = null; } this.svgBackground_ = null; @@ -527,7 +526,7 @@ Blockly.Flyout.prototype.clearOldBlocks_ = function() { for (var j = 0; j < this.mats_.length; j++) { var rect = this.mats_[j]; if (rect) { - goog.dom.removeNode(rect); + rect.parentNode.removeChild(rect); } } this.mats_.length = 0; diff --git a/core/flyout_button.js b/core/flyout_button.js index 6fad650b5..718a9f692 100644 --- a/core/flyout_button.js +++ b/core/flyout_button.js @@ -28,7 +28,6 @@ goog.provide('Blockly.FlyoutButton'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.math.Coordinate'); @@ -240,7 +239,7 @@ Blockly.FlyoutButton.prototype.dispose = function() { Blockly.unbindEvent_(this.onMouseUpWrapper_); } if (this.svgGroup_) { - goog.dom.removeNode(this.svgGroup_); + this.svgGroup_.parentNode.removeChild(this.svgGroup_); this.svgGroup_ = null; } this.workspace_ = null; diff --git a/core/icon.js b/core/icon.js index fcc379c35..51c4d8e0d 100644 --- a/core/icon.js +++ b/core/icon.js @@ -28,7 +28,6 @@ goog.provide('Blockly.Icon'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.math.Coordinate'); @@ -97,7 +96,7 @@ Blockly.Icon.prototype.createIcon = function() { */ Blockly.Icon.prototype.dispose = function() { // Dispose of and unlink the icon. - goog.dom.removeNode(this.iconGroup_); + this.iconGroup_.parentNode.removeChild(this.iconGroup_); this.iconGroup_ = null; // Dispose of and unlink the bubble. this.setVisible(false); diff --git a/core/rendered_connection.js b/core/rendered_connection.js index c39f5b989..cfcc375e3 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -29,7 +29,6 @@ goog.provide('Blockly.RenderedConnection'); goog.require('Blockly.Connection'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.math.Coordinate'); @@ -263,7 +262,7 @@ Blockly.RenderedConnection.prototype.unhideAll = function() { * Remove the highlighting around this connection. */ Blockly.RenderedConnection.prototype.unhighlight = function() { - goog.dom.removeNode(Blockly.Connection.highlightedPath_); + Blockly.Connection.highlightedPath_.parentNode.removeChild(Blockly.Connection.highlightedPath_); delete Blockly.Connection.highlightedPath_; }; diff --git a/core/scrollbar.js b/core/scrollbar.js index 22db386c9..5af4c3163 100644 --- a/core/scrollbar.js +++ b/core/scrollbar.js @@ -29,7 +29,6 @@ goog.provide('Blockly.ScrollbarPair'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.events.BrowserFeature'); goog.require('goog.math.Coordinate'); @@ -73,7 +72,7 @@ Blockly.ScrollbarPair.prototype.oldHostMetrics_ = null; * Unlink from all DOM elements to prevent memory leaks. */ Blockly.ScrollbarPair.prototype.dispose = function() { - goog.dom.removeNode(this.corner_); + this.corner_.parentNode.removeChild(this.corner_); this.corner_ = null; this.workspace_ = null; this.oldHostMetrics_ = null; @@ -348,7 +347,7 @@ Blockly.Scrollbar.prototype.dispose = function() { Blockly.unbindEvent_(this.onMouseDownHandleWrapper_); this.onMouseDownHandleWrapper_ = null; - goog.dom.removeNode(this.outerSvg_); + this.outerSvg_.parentNode.removeChild(this.outerSvg_); this.outerSvg_ = null; this.svgGroup_ = null; this.svgBackground_ = null; diff --git a/core/toolbox.js b/core/toolbox.js index b87929a6b..13d3dcfe8 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -218,7 +218,7 @@ Blockly.Toolbox.prototype.init = function() { Blockly.Toolbox.prototype.dispose = function() { this.flyout_.dispose(); this.tree_.dispose(); - goog.dom.removeNode(this.HtmlDiv); + this.HtmlDiv.parentNode.removeChild(this.HtmlDiv); this.workspace_ = null; this.lastCategory_ = null; }; diff --git a/core/trashcan.js b/core/trashcan.js index 8ffcac17e..6b96a2889 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -28,7 +28,6 @@ goog.provide('Blockly.Trashcan'); goog.require('Blockly.utils'); -goog.require('goog.dom'); goog.require('goog.math.Rect'); @@ -229,7 +228,7 @@ Blockly.Trashcan.prototype.init = function(bottom) { */ Blockly.Trashcan.prototype.dispose = function() { if (this.svgGroup_) { - goog.dom.removeNode(this.svgGroup_); + this.svgGroup_.parentNode.removeChild(this.svgGroup_); this.svgGroup_ = null; } this.svgLid_ = null; diff --git a/core/variables_dynamic.js b/core/variables_dynamic.js index 7ee4d8787..fc76f32a1 100644 --- a/core/variables_dynamic.js +++ b/core/variables_dynamic.js @@ -34,6 +34,8 @@ goog.require('Blockly.VariableModel'); // TODO Fix circular dependencies // goog.require('Blockly.Workspace'); +goog.require('goog.dom'); + Blockly.VariablesDynamic.onCreateVariableButtonClick_String = function(button) { Blockly.Variables.createVariableButtonHandler(button.getTargetWorkspace(), null, 'String'); diff --git a/core/workspace_comment_svg.js b/core/workspace_comment_svg.js index 8786f4488..9205ad350 100644 --- a/core/workspace_comment_svg.js +++ b/core/workspace_comment_svg.js @@ -118,7 +118,7 @@ Blockly.WorkspaceCommentSvg.prototype.dispose = function() { Blockly.Events.fire(new Blockly.Events.CommentDelete(this)); } - goog.dom.removeNode(this.svgGroup_); + this.svgGroup_.parentNode.removeChild(this.svgGroup_); // Sever JavaScript to DOM connections. this.svgGroup_ = null; this.svgRect_ = null; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index dcc4cddef..8e32e29a9 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -494,7 +494,7 @@ Blockly.WorkspaceSvg.prototype.dispose = function() { } Blockly.WorkspaceSvg.superClass_.dispose.call(this); if (this.svgGroup_) { - goog.dom.removeNode(this.svgGroup_); + this.svgGroup_.parentNode.removeChild(this.svgGroup_); this.svgGroup_ = null; } this.svgBlockCanvas_ = null; diff --git a/core/xml.js b/core/xml.js index a79ff65ec..ddb608e7b 100644 --- a/core/xml.js +++ b/core/xml.js @@ -289,7 +289,7 @@ Blockly.Xml.cloneShadow_ = function(shadow) { if (textNode.nodeType == 3 && textNode.data.trim() == '' && node.firstChild != textNode) { // Prune whitespace after a tag. - goog.dom.removeNode(textNode); + textNode.parentNode.removeChild(textNode); } } if (node) { @@ -297,7 +297,7 @@ Blockly.Xml.cloneShadow_ = function(shadow) { node = node.nextSibling; if (textNode.nodeType == 3 && textNode.data.trim() == '') { // Prune whitespace before a tag. - goog.dom.removeNode(textNode); + textNode.parentNode.removeChild(textNode); } } } diff --git a/core/zoom_controls.js b/core/zoom_controls.js index e8af00d40..40908a99b 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -29,8 +29,6 @@ goog.provide('Blockly.ZoomControls'); goog.require('Blockly.Touch'); goog.require('Blockly.utils'); -goog.require('goog.dom'); - /** * Class for a zoom controls. @@ -124,7 +122,7 @@ Blockly.ZoomControls.prototype.init = function(bottom) { */ Blockly.ZoomControls.prototype.dispose = function() { if (this.svgGroup_) { - goog.dom.removeNode(this.svgGroup_); + this.svgGroup_.parentNode.removeChild(this.svgGroup_); this.svgGroup_ = null; } this.workspace_ = null;