diff --git a/core/block_events.js b/core/block_events.js
index a062bea49..0c3ad6cbc 100644
--- a/core/block_events.js
+++ b/core/block_events.js
@@ -36,8 +36,7 @@ goog.provide('Blockly.Events.Move'); // Deprecated.
goog.require('Blockly.Events');
goog.require('Blockly.Events.Abstract');
-// TODO Fix circular dependencies
-//goog.require('Blockly.Xml');
+goog.require('Blockly.Xml.utils');
goog.require('goog.math.Coordinate');
@@ -274,7 +273,7 @@ Blockly.Events.Create.prototype.fromJson = function(json) {
Blockly.Events.Create.prototype.run = function(forward) {
var workspace = this.getEventWorkspace_();
if (forward) {
- var xml = Blockly.Xml.createElement('xml');
+ var xml = Blockly.Xml.utils.createElement('xml');
xml.appendChild(this.xml);
Blockly.Xml.domToWorkspace(xml, workspace);
} else {
@@ -364,7 +363,7 @@ Blockly.Events.Delete.prototype.run = function(forward) {
}
}
} else {
- var xml = Blockly.Xml.createElement('xml');
+ var xml = Blockly.Xml.utils.createElement('xml');
xml.appendChild(this.oldXml);
Blockly.Xml.domToWorkspace(xml, workspace);
}
diff --git a/core/blockly.js b/core/blockly.js
index 87a41bda4..765a6ff82 100644
--- a/core/blockly.js
+++ b/core/blockly.js
@@ -27,7 +27,7 @@
/**
* The top level namespace used to access the Blockly library.
* @namespace Blockly
- **/
+ */
goog.provide('Blockly');
goog.require('Blockly.BlockSvg.render');
diff --git a/core/extensions.js b/core/extensions.js
index 1379f2f18..0b1215d7d 100644
--- a/core/extensions.js
+++ b/core/extensions.js
@@ -30,7 +30,7 @@
/**
* @name Blockly.Extensions
* @namespace
- **/
+ */
goog.provide('Blockly.Extensions');
goog.require('Blockly.Mutator');
diff --git a/core/field.js b/core/field.js
index 229bfa727..c5e577ce7 100644
--- a/core/field.js
+++ b/core/field.js
@@ -379,7 +379,7 @@ Blockly.Field.prototype.render_ = function() {
* Updates thw width of the field. This calls getCachedWidth which won't cache
* the approximated width on IE/Edge when `getComputedTextLength` fails. Once
* it eventually does succeed, the result will be cached.
- **/
+ */
Blockly.Field.prototype.updateWidth = function() {
var width = Blockly.Field.getCachedWidth(this.textElement_);
if (this.borderRect_) {
diff --git a/core/mutator.js b/core/mutator.js
index 3f5cf1c98..b1367749c 100644
--- a/core/mutator.js
+++ b/core/mutator.js
@@ -34,6 +34,7 @@ goog.require('Blockly.Icon');
goog.require('Blockly.utils');
goog.require('Blockly.WorkspaceSvg');
goog.require('Blockly.Xml');
+goog.require('Blockly.Xml.utils');
/**
@@ -130,9 +131,9 @@ Blockly.Mutator.prototype.createEditor_ = function() {
null);
// Convert the list of names into a list of XML objects for the flyout.
if (this.quarkNames_.length) {
- var quarkXml = Blockly.Xml.createElement('xml');
+ var quarkXml = Blockly.Xml.utils.createElement('xml');
for (var i = 0, quarkName; quarkName = this.quarkNames_[i]; i++) {
- var element = Blockly.Xml.createElement('block');
+ var element = Blockly.Xml.utils.createElement('block');
element.setAttribute('type', quarkName);
quarkXml.appendChild(element);
}
diff --git a/core/options.js b/core/options.js
index f9ab04005..5b3e4ba81 100644
--- a/core/options.js
+++ b/core/options.js
@@ -133,7 +133,7 @@ Blockly.Options = function(options) {
/**
* The parent of the current workspace, or null if there is no parent workspace.
* @type {Blockly.Workspace}
- **/
+ */
Blockly.Options.prototype.parentWorkspace = null;
/**
diff --git a/core/procedures.js b/core/procedures.js
index 59ec20a89..cc84a4902 100644
--- a/core/procedures.js
+++ b/core/procedures.js
@@ -27,7 +27,7 @@
/**
* @name Blockly.Procedures
* @namespace
- **/
+ */
goog.provide('Blockly.Procedures');
goog.require('Blockly.Blocks');
@@ -37,6 +37,7 @@ goog.require('Blockly.Field');
goog.require('Blockly.Names');
goog.require('Blockly.Workspace');
goog.require('Blockly.Xml');
+goog.require('Blockly.Xml.utils');
/**
@@ -185,12 +186,12 @@ Blockly.Procedures.flyoutCategory = function(workspace) {
//
// do something
//
- var block = Blockly.Xml.createElement('block');
+ var block = Blockly.Xml.utils.createElement('block');
block.setAttribute('type', 'procedures_defnoreturn');
block.setAttribute('gap', 16);
- var nameField = Blockly.Xml.createElement('field');
+ var nameField = Blockly.Xml.utils.createElement('field');
nameField.setAttribute('name', 'NAME');
- nameField.appendChild(Blockly.Xml.createTextNode(
+ nameField.appendChild(Blockly.Xml.utils.createTextNode(
Blockly.Msg['PROCEDURES_DEFNORETURN_PROCEDURE']));
block.appendChild(nameField);
xmlList.push(block);
@@ -199,19 +200,19 @@ Blockly.Procedures.flyoutCategory = function(workspace) {
//
// do something
//
- var block = Blockly.Xml.createElement('block');
+ var block = Blockly.Xml.utils.createElement('block');
block.setAttribute('type', 'procedures_defreturn');
block.setAttribute('gap', 16);
- var nameField = Blockly.Xml.createElement('field');
+ var nameField = Blockly.Xml.utils.createElement('field');
nameField.setAttribute('name', 'NAME');
- nameField.appendChild(Blockly.Xml.createTextNode(
+ nameField.appendChild(Blockly.Xml.utils.createTextNode(
Blockly.Msg['PROCEDURES_DEFRETURN_PROCEDURE']));
block.appendChild(nameField);
xmlList.push(block);
}
if (Blockly.Blocks['procedures_ifreturn']) {
//
- var block = Blockly.Xml.createElement('block');
+ var block = Blockly.Xml.utils.createElement('block');
block.setAttribute('type', 'procedures_ifreturn');
block.setAttribute('gap', 16);
xmlList.push(block);
@@ -230,14 +231,14 @@ Blockly.Procedures.flyoutCategory = function(workspace) {
//
//
//
- var block = Blockly.Xml.createElement('block');
+ var block = Blockly.Xml.utils.createElement('block');
block.setAttribute('type', templateName);
block.setAttribute('gap', 16);
- var mutation = Blockly.Xml.createElement('mutation');
+ var mutation = Blockly.Xml.utils.createElement('mutation');
mutation.setAttribute('name', name);
block.appendChild(mutation);
for (var j = 0; j < args.length; j++) {
- var arg = Blockly.Xml.createElement('arg');
+ var arg = Blockly.Xml.utils.createElement('arg');
arg.setAttribute('name', args[j]);
mutation.appendChild(arg);
}
diff --git a/core/tooltip.js b/core/tooltip.js
index cea221c7e..3abf7787f 100644
--- a/core/tooltip.js
+++ b/core/tooltip.js
@@ -32,7 +32,7 @@
/**
* @name Blockly.Tooltip
* @namespace
- **/
+ */
goog.provide('Blockly.Tooltip');
goog.require('Blockly.utils');
diff --git a/core/touch.js b/core/touch.js
index 8655211dd..eb5099d36 100644
--- a/core/touch.js
+++ b/core/touch.js
@@ -27,7 +27,7 @@
/**
* @name Blockly.Touch
* @namespace
- **/
+ */
goog.provide('Blockly.Touch');
goog.require('Blockly.utils');
diff --git a/core/ui_menu_utils.js b/core/ui_menu_utils.js
index 8fda6021a..a8c68447b 100644
--- a/core/ui_menu_utils.js
+++ b/core/ui_menu_utils.js
@@ -27,7 +27,7 @@
/**
* @name Blockly.utils.uiMenu
* @namespace
- **/
+ */
goog.provide('Blockly.utils.uiMenu');
diff --git a/core/utils.js b/core/utils.js
index ebfe37ba6..a1b167c78 100644
--- a/core/utils.js
+++ b/core/utils.js
@@ -29,7 +29,7 @@
/**
* @name Blockly.utils
* @namespace
- **/
+ */
goog.provide('Blockly.utils');
goog.require('goog.dom');
diff --git a/core/variables.js b/core/variables.js
index 2dfcd1cf3..38a0cb1ab 100644
--- a/core/variables.js
+++ b/core/variables.js
@@ -27,7 +27,7 @@
/**
* @name Blockly.Variables
* @namespace
- **/
+ */
goog.provide('Blockly.Variables');
goog.require('Blockly.Blocks');
diff --git a/core/widgetdiv.js b/core/widgetdiv.js
index 82de6a02b..ccb7d5554 100644
--- a/core/widgetdiv.js
+++ b/core/widgetdiv.js
@@ -29,7 +29,7 @@
/**
* @name Blockly.WidgetDiv
* @namespace
- **/
+ */
goog.provide('Blockly.WidgetDiv');
goog.require('Blockly.Css');
diff --git a/core/workspace_comment.js b/core/workspace_comment.js
index 290e2d0c1..514775040 100644
--- a/core/workspace_comment.js
+++ b/core/workspace_comment.js
@@ -31,7 +31,7 @@ goog.require('Blockly.Events.CommentCreate');
goog.require('Blockly.Events.CommentDelete');
goog.require('Blockly.Events.CommentMove');
goog.require('Blockly.utils');
-goog.require('Blockly.Xml');
+goog.require('Blockly.Xml.utils');
goog.require('goog.math.Coordinate');
@@ -278,7 +278,7 @@ Blockly.WorkspaceComment.prototype.toXmlWithXY = function(opt_noId) {
* @package
*/
Blockly.WorkspaceComment.prototype.toXml = function(opt_noId) {
- var commentElement = Blockly.Xml.createElement('comment');
+ var commentElement = Blockly.Xml.utils.createElement('comment');
if (!opt_noId) {
commentElement.setAttribute('id', this.id);
}
diff --git a/core/ws_comment_events.js b/core/ws_comment_events.js
index da644ffbe..0e26f1e4f 100644
--- a/core/ws_comment_events.js
+++ b/core/ws_comment_events.js
@@ -33,6 +33,7 @@ goog.provide('Blockly.Events.CommentMove');
goog.require('Blockly.Events');
goog.require('Blockly.Events.Abstract');
goog.require('Blockly.Xml');
+goog.require('Blockly.Xml.utils');
goog.require('goog.math.Coordinate');
@@ -227,7 +228,7 @@ Blockly.Events.CommentCreate.prototype.run = function(forward) {
Blockly.Events.CommentCreateDeleteHelper = function(event, create) {
var workspace = event.getEventWorkspace_();
if (create) {
- var xml = Blockly.Xml.createElement('xml');
+ var xml = Blockly.Xml.utils.createElement('xml');
xml.appendChild(event.xml);
Blockly.Xml.domToWorkspace(xml, workspace);
} else {
diff --git a/core/xml.js b/core/xml.js
index 5f8ccef55..2ddd08480 100644
--- a/core/xml.js
+++ b/core/xml.js
@@ -27,11 +27,12 @@
/**
* @name Blockly.Xml
* @namespace
- **/
+ */
goog.provide('Blockly.Xml');
goog.require('Blockly.Events.BlockCreate');
goog.require('Blockly.Events.VarCreate');
+goog.require('Blockly.Xml.utils');
/**
@@ -41,7 +42,7 @@ goog.require('Blockly.Events.VarCreate');
* @return {!Element} XML document.
*/
Blockly.Xml.workspaceToDom = function(workspace, opt_noId) {
- var xml = Blockly.Xml.createElement('xml');
+ var xml = Blockly.Xml.utils.createElement('xml');
var variablesElement = Blockly.Xml.variablesToDom(
Blockly.Variables.allUsedVarModels(workspace));
if (variablesElement.hasChildNodes()) {
@@ -65,10 +66,10 @@ Blockly.Xml.workspaceToDom = function(workspace, opt_noId) {
* @return {!Element} List of XML elements.
*/
Blockly.Xml.variablesToDom = function(variableList) {
- var variables = Blockly.Xml.createElement('variables');
+ var variables = Blockly.Xml.utils.createElement('variables');
for (var i = 0, variable; variable = variableList[i]; i++) {
- var element = Blockly.Xml.createElement('variable');
- element.appendChild(Blockly.Xml.createTextNode(variable.name));
+ var element = Blockly.Xml.utils.createElement('variable');
+ element.appendChild(Blockly.Xml.utils.createTextNode(variable.name));
element.setAttribute('type', variable.type);
element.setAttribute('id', variable.getId());
variables.appendChild(element);
@@ -122,8 +123,8 @@ Blockly.Xml.fieldToDomVariable_ = function(field) {
if (!variable) {
throw Error('Tried to serialize a variable field with no variable.');
}
- var container = Blockly.Xml.createElement('field');
- container.appendChild(Blockly.Xml.createTextNode(variable.name));
+ var container = Blockly.Xml.utils.createElement('field');
+ container.appendChild(Blockly.Xml.utils.createTextNode(variable.name));
container.setAttribute('name', field.name);
container.setAttribute('id', variable.getId());
container.setAttribute('variabletype', variable.type);
@@ -142,8 +143,8 @@ Blockly.Xml.fieldToDom_ = function(field) {
if (field.referencesVariables()) {
return Blockly.Xml.fieldToDomVariable_(field);
} else {
- var container = Blockly.Xml.createElement('field');
- container.appendChild(Blockly.Xml.createTextNode(field.getValue()));
+ var container = Blockly.Xml.utils.createElement('field');
+ container.appendChild(Blockly.Xml.utils.createTextNode(field.getValue()));
container.setAttribute('name', field.name);
return container;
}
@@ -177,7 +178,7 @@ Blockly.Xml.allFieldsToDom_ = function(block, element) {
* @return {!Element} Tree of XML elements.
*/
Blockly.Xml.blockToDom = function(block, opt_noId) {
- var element = Blockly.Xml.createElement(block.isShadow() ? 'shadow' : 'block');
+ var element = Blockly.Xml.utils.createElement(block.isShadow() ? 'shadow' : 'block');
element.setAttribute('type', block.type);
if (!opt_noId) {
element.setAttribute('id', block.id);
@@ -194,8 +195,8 @@ Blockly.Xml.blockToDom = function(block, opt_noId) {
var commentText = block.getCommentText();
if (commentText) {
- var commentElement = Blockly.Xml.createElement('comment');
- containerElement.appendChild(Blockly.Xml.createTextNode(commentText));
+ var commentElement = Blockly.Xml.utils.createElement('comment');
+ containerElement.appendChild(Blockly.Xml.utils.createTextNode(commentText));
if (typeof block.comment == 'object') {
commentElement.setAttribute('pinned', block.comment.isVisible());
var hw = block.comment.getBubbleSize();
@@ -206,8 +207,8 @@ Blockly.Xml.blockToDom = function(block, opt_noId) {
}
if (block.data) {
- var dataElement = Blockly.Xml.createElement('data');
- dataElement.appendChild(Blockly.Xml.createTextNode(block.data));
+ var dataElement = Blockly.Xml.utils.createElement('data');
+ dataElement.appendChild(Blockly.Xml.utils.createTextNode(block.data));
element.appendChild(dataElement);
}
@@ -219,9 +220,9 @@ Blockly.Xml.blockToDom = function(block, opt_noId) {
} else {
var childBlock = input.connection.targetBlock();
if (input.type == Blockly.INPUT_VALUE) {
- container = Blockly.Xml.createElement('value');
+ container = Blockly.Xml.utils.createElement('value');
} else if (input.type == Blockly.NEXT_STATEMENT) {
- container = Blockly.Xml.createElement('statement');
+ container = Blockly.Xml.utils.createElement('statement');
}
var shadow = input.connection.getShadowDom();
if (shadow && (!childBlock || !childBlock.isShadow())) {
@@ -258,8 +259,8 @@ Blockly.Xml.blockToDom = function(block, opt_noId) {
var nextBlock = block.getNextBlock();
if (nextBlock) {
- var container = Blockly.Xml.createElement('next');
- container.appendChild(Blockly.Xml.createTextNode(
+ var container = Blockly.Xml.utils.createElement('next');
+ container.appendChild(Blockly.Xml.utils.createTextNode(
Blockly.Xml.blockToDom(nextBlock, opt_noId)));
element.appendChild(container);
}
@@ -866,27 +867,6 @@ Blockly.Xml.deleteNext = function(xmlBlock) {
}
};
-/**
- * Create DOM element for XML.
- * @param {tagName} name Name of DOM element.
- * @return {!Element} New DOM element.
- */
-Blockly.Xml.createElement = function(tagName) {
- // TODO: Namespace this element.
- // TODO: Support node.js.
- return document.createElement(tagName);
-};
-
-/**
- * Create text element for XML.
- * @param {text} text Text content.
- * @return {!Node} New DOM node.
- */
-Blockly.Xml.createTextNode = function(text) {
- // TODO: Support node.js.
- return document.createTextNode(text);
-};
-
// Export symbols that would otherwise be renamed by Closure compiler.
if (!goog.global['Blockly']) {
goog.global['Blockly'] = {};
diff --git a/core/xml_utils.js b/core/xml_utils.js
new file mode 100644
index 000000000..1dea3c83d
--- /dev/null
+++ b/core/xml_utils.js
@@ -0,0 +1,54 @@
+/**
+ * @license
+ * Visual Blocks Editor
+ *
+ * Copyright 2018 Google Inc.
+ * https://developers.google.com/blockly/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview XML element manipulation.
+ * @author fraser@google.com (Neil Fraser)
+ */
+'use strict';
+
+/**
+ * @name Blockly.Xml.utils
+ * @namespace
+ */
+goog.provide('Blockly.Xml.utils');
+
+
+/**
+ * Create DOM element for XML.
+ * @param {tagName} name Name of DOM element.
+ * @return {!Element} New DOM element.
+ */
+Blockly.Xml.utils.createElement = function(tagName) {
+ // TODO: Namespace this element.
+ // TODO: Support node.js.
+ return document.createElement(tagName);
+};
+
+/**
+ * Create text element for XML.
+ * @param {text} text Text content.
+ * @return {!Node} New DOM node.
+ */
+Blockly.Xml.utils.createTextNode = function(text) {
+ // TODO: Support node.js.
+ return document.createTextNode(text);
+};
+