mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
Don't monkey-patch Blocky.utils.xml.document (#5461)
Use Blockly.utils.xml.setDocument instead.
This commit is contained in:
committed by
GitHub
parent
f4430e9e47
commit
d202ae0201
@@ -24,11 +24,10 @@ Blockly.setLocale = function (locale) {
|
||||
// XMLSerializer.
|
||||
const globalThis = Blockly.utils.global.globalThis;
|
||||
if (typeof globalThis.document !== 'object') {
|
||||
globalThis.DOMParser = require('jsdom/lib/jsdom/living').DOMParser;
|
||||
globalThis.XMLSerializer = require('jsdom/lib/jsdom/living').XMLSerializer;
|
||||
var doc = Blockly.utils.xml.textToDomDocument(
|
||||
'<xml xmlns="https://developers.google.com/blockly/xml"></xml>');
|
||||
Blockly.utils.xml.document = function() {
|
||||
return doc;
|
||||
};
|
||||
const jsdom = require('jsdom/lib/jsdom/living');
|
||||
globalThis.DOMParser = jsdom.DOMParser;
|
||||
globalThis.XMLSerializer = jsdom.XMLSerializer;
|
||||
const xmlDocument = Blockly.utils.xml.textToDomDocument(
|
||||
`<xml xmlns="${Blockly.utils.xml.NAME_SPACE}"></xml>`);
|
||||
Blockly.utils.xml.setDocument(xmlDocument);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user