mirror of
https://github.com/google/blockly.git
synced 2026-01-14 20:37:10 +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
@@ -32,7 +32,7 @@ const renamings = {
|
||||
export: 'conditionalBind',
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
'6.20210701.0': {
|
||||
'Blockly': {
|
||||
@@ -70,14 +70,21 @@ const renamings = {
|
||||
'Blockly.utils': {
|
||||
exports: {
|
||||
genUid: {module: 'Blockly.utils.idGenerator'},
|
||||
}
|
||||
},
|
||||
},
|
||||
'Blockly.utils.global': {
|
||||
export: 'globalThis', // Previous default export now named.
|
||||
},
|
||||
'Blockly.utils.IdGenerator': {
|
||||
module: 'Blockly.utils.idGenerator',
|
||||
}
|
||||
},
|
||||
'Blockly.utils.xml': {
|
||||
exports: {
|
||||
// document was a function before, too - not a static property
|
||||
// or get accessor.
|
||||
document: {export: 'getDocument'},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -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