mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Removed textToDom Needing <xml> Documents (#2585)
* Removed textToDom needing <xml> documents. * Fixed jsdoc. * Followon changes resulting from lack of XML tag. * Fix Mocha test.
This commit is contained in:
@@ -26,8 +26,9 @@
|
||||
|
||||
goog.provide('Blockly.Options');
|
||||
|
||||
goog.require('Blockly.Xml');
|
||||
goog.require('Blockly.Themes.Classic');
|
||||
goog.require('Blockly.utils.userAgent');
|
||||
goog.require('Blockly.Xml');
|
||||
|
||||
|
||||
/**
|
||||
@@ -48,7 +49,8 @@ Blockly.Options = function(options) {
|
||||
var hasDisable = false;
|
||||
var hasSounds = false;
|
||||
} else {
|
||||
var languageTree = Blockly.Options.parseToolboxTree(options['toolbox']);
|
||||
var languageTree =
|
||||
Blockly.Options.parseToolboxTree(options['toolbox'] || null);
|
||||
var hasCategories = Boolean(languageTree &&
|
||||
languageTree.getElementsByTagName('category').length);
|
||||
var hasTrashcan = options['trashcan'];
|
||||
@@ -263,11 +265,11 @@ Blockly.Options.parseGridOptions_ = function(options) {
|
||||
Blockly.Options.parseToolboxTree = function(tree) {
|
||||
if (tree) {
|
||||
if (typeof tree != 'string') {
|
||||
if (typeof XSLTProcessor == 'undefined' && tree.outerHTML) {
|
||||
if (Blockly.utils.userAgent.IE && tree.outerHTML) {
|
||||
// In this case the tree will not have been properly built by the
|
||||
// browser. The HTML will be contained in the element, but it will
|
||||
// not have the proper DOM structure since the browser doesn't support
|
||||
// XSLTProcessor (XML -> HTML). This is the case in IE 9+.
|
||||
// XSLTProcessor (XML -> HTML).
|
||||
tree = tree.outerHTML;
|
||||
} else if (!(tree instanceof Element)) {
|
||||
tree = null;
|
||||
@@ -275,6 +277,9 @@ Blockly.Options.parseToolboxTree = function(tree) {
|
||||
}
|
||||
if (typeof tree == 'string') {
|
||||
tree = Blockly.Xml.textToDom(tree);
|
||||
if (tree.nodeName.toLowerCase() != 'xml') {
|
||||
throw TypeError('Toolbox should be an <xml> document.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tree = null;
|
||||
|
||||
Reference in New Issue
Block a user