Make sure we have a proper node before parsing

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-04-15 13:04:51 +02:00 committed by Backportbot
parent 8b2a3994a6
commit b3c390ea1e
1 changed files with 5 additions and 0 deletions

View File

@ -82,6 +82,11 @@
var parts = name.split(':');
var tagName = parts[1];
var namespace = resolver(parts[0]);
// make sure we can get elements
if (typeof node === 'string') {
var parser = new DOMParser()
node = parser.parseFromString(node, 'text/xml')
}
if (node.getElementsByTagNameNS) {
return node.getElementsByTagNameNS(namespace, tagName);
}