blockly > utils > xml > injectDependencies

utils.xml.injectDependencies() function

Inject implementations of document, DOMParser and/or XMLSerializer to use instead of the default ones.

Used by the Node.js wrapper for Blockly (see scripts/package/node/core.js) to supply implementations from the jsdom package instead.

While they may be set individually, it is normally the case that all three will be sourced from the same JSDOM instance. They MUST at least come from the same copy of the jsdom package. (Typically this is hard to avoid satsifying this requirement, but it can be inadvertently violated by using webpack to build multiple bundles containing Blockly and jsdom, and then loading more than one into the same JavaScript runtime. See https://github.com/google/blockly-samples/pull/1452#issuecomment-1364442135 for an example of how this happened.)

Signature:

export declare function injectDependencies(dependencies: {
    document?: Document;
    DOMParser?: typeof DOMParser;
    XMLSerializer?: typeof XMLSerializer;
}): void;

Parameters

Parameter Type Description
dependencies { document?: Document; DOMParser?: typeof DOMParser; XMLSerializer?: typeof XMLSerializer; } Options object containing dependencies to set.

Returns:

void