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
parent b8511f4835
commit 6c593e5b32
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
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);
}