Use Element constants and ‘i’ variable.

I don’t care about whether we use the Element constants or the ubiquitously known 1 & 3 integers.  But we had a mix.
Also, ’x’ is usually used for horizontal location, ‘i’ is an iterator.
No functional change.
This commit is contained in:
Neil Fraser
2019-05-01 21:18:19 -07:00
committed by Neil Fraser
parent 6f433d7521
commit 834fa64674
4 changed files with 9 additions and 8 deletions

View File

@@ -907,7 +907,7 @@ Blockly.BlockSvg.prototype.renderInlineRow_ = function(pathObject, row, cursor,
var steps = pathObject.steps;
var highlightSteps = pathObject.highlightSteps;
for (var x = 0, input; input = row[x]; x++) {
for (var i = 0, input; input = row[i]; i++) {
var fieldX = cursor.x;
var fieldY = cursor.y;
if (row.thicker) {

View File

@@ -404,7 +404,7 @@ Blockly.Flyout.prototype.hide = function() {
}
this.setVisible(false);
// Delete all the event listeners.
for (var x = 0, listen; listen = this.listeners_[x]; x++) {
for (var i = 0, listen; listen = this.listeners_[i]; i++) {
Blockly.unbindEvent_(listen);
}
this.listeners_.length = 0;

View File

@@ -96,7 +96,7 @@ Blockly.Generator.prototype.workspaceToCode = function(workspace) {
var code = [];
this.init(workspace);
var blocks = workspace.getTopBlocks(true);
for (var x = 0, block; block = blocks[x]; x++) {
for (var i = 0, block; block = blocks[i]; i++) {
var line = this.blockToCode(block);
if (Array.isArray(line)) {
// Value blocks return tuples of code and operator order.

View File

@@ -250,8 +250,8 @@ Blockly.Xml.cloneShadow_ = function(shadow) {
while (node && !node.nextSibling) {
textNode = node;
node = node.parentNode;
if (textNode.nodeType == 3 && textNode.data.trim() == '' &&
node.firstChild != textNode) {
if (textNode.nodeType == Element.TEXT_NODE &&
textNode.data.trim() == '' && node.firstChild != textNode) {
// Prune whitespace after a tag.
Blockly.utils.removeNode(textNode);
}
@@ -259,7 +259,8 @@ Blockly.Xml.cloneShadow_ = function(shadow) {
if (node) {
textNode = node;
node = node.nextSibling;
if (textNode.nodeType == 3 && textNode.data.trim() == '') {
if (textNode.nodeType == Element.TEXT_NODE &&
textNode.data.trim() == '') {
// Prune whitespace before a tag.
Blockly.utils.removeNode(textNode);
}
@@ -594,7 +595,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) {
var blockChild = null;
for (var i = 0, xmlChild; xmlChild = xmlBlock.childNodes[i]; i++) {
if (xmlChild.nodeType == 3) {
if (xmlChild.nodeType == Element.TEXT_NODE) {
// Ignore any text at the <block> level. It's all whitespace anyway.
continue;
}
@@ -604,7 +605,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 == 1) {
if (grandchild.nodeType == Element.ELEMENT_NODE) {
if (grandchild.nodeName.toLowerCase() == 'block') {
childBlockElement = /** @type {!Element} */ (grandchild);
} else if (grandchild.nodeName.toLowerCase() == 'shadow') {