Remove goog.dom.removeNode

This commit is contained in:
Neil Fraser
2018-06-29 15:58:41 -07:00
committed by Neil Fraser
parent f802859547
commit c51cf0b79c
19 changed files with 36 additions and 42 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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_();

View File

@@ -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;
};

View File

@@ -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;
}
};
/**

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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_;
};

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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;

View File

@@ -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');

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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;