Replace Element constants with Node constants.

Element constants apparently don’t exist in IE or Edge.  Node constants apparently do.
This commit is contained in:
Neil Fraser
2019-05-25 23:35:19 -07:00
committed by Neil Fraser
parent a03f0859cc
commit 459961c3cb
3 changed files with 5 additions and 38 deletions

View File

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

View File

@@ -1,32 +0,0 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2019 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 Property definitions in browsers that Closure Compiler is
* unaware of.
* @author fraser@google.com (Neil Fraser)
*
* @externs
*/
'use strict';
Element.ELEMENT_NODE = 1;
Element.TEXT_NODE = 3;

View File

@@ -82,7 +82,6 @@ COMPILATION_COMMAND="java -jar $COMPILER --js='$BLOCKLY_ROOT/tests/compile/main.
--js='$CLOSURE_LIB_ROOT/closure/goog/**.js' \
--js='$CLOSURE_LIB_ROOT/third_party/closure/goog/**.js' \
--generate_exports \
--externs $BLOCKLY_ROOT/externs/browser-externs.js \
--externs $BLOCKLY_ROOT/externs/svg-externs.js \
--compilation_level ADVANCED_OPTIMIZATIONS \
--dependency_mode=STRICT --entry_point=Main \