Replacing node.parentNode.removeChild(node)

...with Blockly.utils.removeNode(..), which includes
a null/undefined check on parentNode before continuing.
This commit is contained in:
Andrew n marshall
2018-09-04 13:31:53 -07:00
parent 852960afcd
commit 411ec9724e
19 changed files with 33 additions and 23 deletions

View File

@@ -114,6 +114,16 @@ Blockly.utils.hasClass = function(element, className) {
return (' ' + classes + ' ').indexOf(' ' + className + ' ') != -1;
};
/**
* Removes a node from its parent. No-op if not attached to a parent.
* @param {Node} node The node to remove.
* @return {Node} The node removed if removed; else, null.
*/
// Copied from Closure goog.dom.removeNode
Blockly.utils.removeNode = function(node) {
return node && node.parentNode ? node.parentNode.removeChild(node) : null;
};
/**
* Don't do anything for this event, just halt propagation.
* @param {!Event} e An event.