mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Rename dom Node enum (#3824)
* Rename Node enum to NodeType to avoid conflict with type Node
This commit is contained in:
@@ -476,7 +476,8 @@ Blockly.Component.prototype.addChildAt = function(child, index, opt_render) {
|
||||
child.element_.parentNode &&
|
||||
// Under some circumstances, IE8 implicitly creates a Document Fragment
|
||||
// for detached nodes, so ensure the parent is an Element as it should be.
|
||||
child.element_.parentNode.nodeType == Blockly.utils.dom.Node.ELEMENT_NODE) {
|
||||
child.element_.parentNode.nodeType ==
|
||||
Blockly.utils.dom.NodeType.ELEMENT_NODE) {
|
||||
// We don't touch the DOM, but if the parent is in the document, and the
|
||||
// child element is in the document but not marked as such, then we call
|
||||
// enterDocument on the child.
|
||||
|
||||
@@ -44,7 +44,7 @@ Blockly.utils.dom.XLINK_NS = 'http://www.w3.org/1999/xlink';
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
||||
* @enum {number}
|
||||
*/
|
||||
Blockly.utils.dom.Node = {
|
||||
Blockly.utils.dom.NodeType = {
|
||||
ELEMENT_NODE: 1,
|
||||
TEXT_NODE: 3,
|
||||
COMMENT_NODE: 8,
|
||||
@@ -76,10 +76,10 @@ Blockly.utils.dom.canvasContext_ = null;
|
||||
* Helper method for creating SVG elements.
|
||||
* @param {string} name Element's tag name.
|
||||
* @param {!Object} attrs Dictionary of attribute names and values.
|
||||
* @param {Element} parent Optional parent on which to append the element.
|
||||
* @param {Element=} opt_parent Optional parent on which to append the element.
|
||||
* @return {!SVGElement} Newly created SVG element.
|
||||
*/
|
||||
Blockly.utils.dom.createSvgElement = function(name, attrs, parent) {
|
||||
Blockly.utils.dom.createSvgElement = function(name, attrs, opt_parent) {
|
||||
var e = /** @type {!SVGElement} */
|
||||
(document.createElementNS(Blockly.utils.dom.SVG_NS, name));
|
||||
for (var key in attrs) {
|
||||
@@ -91,8 +91,8 @@ Blockly.utils.dom.createSvgElement = function(name, attrs, parent) {
|
||||
if (document.body.runtimeStyle) { // Indicates presence of IE-only attr.
|
||||
e.runtimeStyle = e.currentStyle = e.style;
|
||||
}
|
||||
if (parent) {
|
||||
parent.appendChild(e);
|
||||
if (opt_parent) {
|
||||
opt_parent.appendChild(e);
|
||||
}
|
||||
return e;
|
||||
};
|
||||
@@ -192,7 +192,7 @@ Blockly.utils.dom.insertAfter = function(newNode, refNode) {
|
||||
*/
|
||||
Blockly.utils.dom.containsNode = function(parent, descendant) {
|
||||
return !!(parent.compareDocumentPosition(descendant) &
|
||||
Blockly.utils.dom.Node.DOCUMENT_POSITION_CONTAINED_BY);
|
||||
Blockly.utils.dom.NodeType.DOCUMENT_POSITION_CONTAINED_BY);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
11
core/xml.js
11
core/xml.js
@@ -253,7 +253,7 @@ Blockly.Xml.cloneShadow_ = function(shadow, opt_noId) {
|
||||
while (node && !node.nextSibling) {
|
||||
textNode = node;
|
||||
node = node.parentNode;
|
||||
if (textNode.nodeType == Blockly.utils.dom.Node.TEXT_NODE &&
|
||||
if (textNode.nodeType == Blockly.utils.dom.NodeType.TEXT_NODE &&
|
||||
textNode.data.trim() == '' && node.firstChild != textNode) {
|
||||
// Prune whitespace after a tag.
|
||||
Blockly.utils.dom.removeNode(textNode);
|
||||
@@ -262,7 +262,8 @@ Blockly.Xml.cloneShadow_ = function(shadow, opt_noId) {
|
||||
if (node) {
|
||||
textNode = node;
|
||||
node = node.nextSibling;
|
||||
if (textNode.nodeType == Blockly.utils.dom.Node.TEXT_NODE && textNode.data.trim() == '') {
|
||||
if (textNode.nodeType == Blockly.utils.dom.NodeType.TEXT_NODE &&
|
||||
textNode.data.trim() == '') {
|
||||
// Prune whitespace before a tag.
|
||||
Blockly.utils.dom.removeNode(textNode);
|
||||
}
|
||||
@@ -583,7 +584,7 @@ Blockly.Xml.domToBlock = function(xmlBlock, workspace) {
|
||||
*/
|
||||
Blockly.Xml.domToVariables = function(xmlVariables, workspace) {
|
||||
for (var i = 0, xmlChild; (xmlChild = xmlVariables.childNodes[i]); i++) {
|
||||
if (xmlChild.nodeType != Blockly.utils.dom.Node.ELEMENT_NODE) {
|
||||
if (xmlChild.nodeType != Blockly.utils.dom.NodeType.ELEMENT_NODE) {
|
||||
continue; // Skip text nodes.
|
||||
}
|
||||
var type = xmlChild.getAttribute('type');
|
||||
@@ -613,7 +614,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) {
|
||||
|
||||
var blockChild = null;
|
||||
for (var i = 0, xmlChild; (xmlChild = xmlBlock.childNodes[i]); i++) {
|
||||
if (xmlChild.nodeType == Blockly.utils.dom.Node.TEXT_NODE) {
|
||||
if (xmlChild.nodeType == Blockly.utils.dom.NodeType.TEXT_NODE) {
|
||||
// Ignore any text at the <block> level. It's all whitespace anyway.
|
||||
continue;
|
||||
}
|
||||
@@ -623,7 +624,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) {
|
||||
var childBlockElement = null;
|
||||
var childShadowElement = null;
|
||||
for (var j = 0, grandchild; (grandchild = xmlChild.childNodes[j]); j++) {
|
||||
if (grandchild.nodeType == Blockly.utils.dom.Node.ELEMENT_NODE) {
|
||||
if (grandchild.nodeType == Blockly.utils.dom.NodeType.ELEMENT_NODE) {
|
||||
if (grandchild.nodeName.toLowerCase() == 'block') {
|
||||
childBlockElement = /** @type {!Element} */ (grandchild);
|
||||
} else if (grandchild.nodeName.toLowerCase() == 'shadow') {
|
||||
|
||||
Reference in New Issue
Block a user