fix: Handle exception while building version comment (#12801)

This commit is contained in:
Suraj Shetty 2021-04-05 11:45:14 +05:30 committed by GitHub
parent 84e1964521
commit 13e7f453fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -151,19 +151,23 @@ function get_version_comment(version_doc, text) {
let version_comment = "";
let unlinked_content = "";
Array.from($(text)).forEach(element => {
if ($(element).is('a')) {
version_comment += unlinked_content ? frappe.utils.get_form_link('Version', version_doc.name, true, unlinked_content) : "";
unlinked_content = "";
version_comment += element.outerHTML;
} else {
unlinked_content += element.outerHTML || element.textContent;
try {
Array.from($(text)).forEach(element => {
if ($(element).is('a')) {
version_comment += unlinked_content ? frappe.utils.get_form_link('Version', version_doc.name, true, unlinked_content) : "";
unlinked_content = "";
version_comment += element.outerHTML;
} else {
unlinked_content += element.outerHTML || element.textContent;
}
});
if (unlinked_content) {
version_comment += frappe.utils.get_form_link('Version', version_doc.name, true, unlinked_content);
}
});
if (unlinked_content) {
version_comment += frappe.utils.get_form_link('Version', version_doc.name, true, unlinked_content);
return version_comment;
} catch (e) {
// pass
}
return version_comment;
}
return frappe.utils.get_form_link('Version', version_doc.name, true, text);
}