Closed
Description
Recently a change was made to svg_text_utils.js which instantiates a DOMParser at the top level of that module:
plotly.js/src/lib/svg_text_utils.js
Line 22 in ce970f1
This has broken a number of tests I have which do not use a browser (or jsdom etc..) because the DOMParser will be instantiated on import, giving the following:
var parser = new DOMParser();
^
ReferenceError: DOMParser is not defined
at Object.<anonymous> (/home/user/repo/node_modules/plotly.js/src/lib/svg_text_utils.js:22:18)
...
For now I've applied a very quick fix:
var parser;
function cachingParser() {
parser = parser === undefined ? new DOMParser(): parser;
return parser
};
...
var dom = cachingParser().parseFromString(skeleton, 'application/xml'),
childNode = dom.documentElement.firstChild;
...
Can this be updated to something like the above? If not, then does the DOMParser really need to be at the top level?
Metadata
Metadata
Assignees
Labels
No labels