From 90bead86ed4b1e43d675b77a04ebe7cb4e674f7b Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 2 Jun 2012 17:05:23 -0400 Subject: [PATCH] Don't cause problems if no callback passed to Zotero.Attachments methods --- chrome/content/zotero/xpcom/attachments.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 17ce185f85..d29d29b23d 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -220,7 +220,7 @@ Zotero.Attachments = new function(){ var urlRe = /^https?:\/\/[^\s]*$/; var matches = urlRe.exec(url); if (!matches) { - callback(false); + if(callback) callback(false); throw ("Invalid URL '" + url + "' in Zotero.Attachments.importFromURL()"); } @@ -302,7 +302,7 @@ Zotero.Attachments = new function(){ + "'application/pdf' in Attachments.importFromURL()"; Zotero.debug(errString, 2); attachmentItem.erase(); - callback(false, new Error(errString)); + if(callback) callback(false, new Error(errString)); return; } @@ -330,7 +330,7 @@ Zotero.Attachments = new function(){ catch (e) { // Clean up attachmentItem.erase(); - callback(false, e); + if(callback) callback(false, e); throw (e); } @@ -616,7 +616,7 @@ Zotero.Attachments = new function(){ // Clean up var item = Zotero.Items.get(itemID); item.erase(); - callback(false, e); + if(callback) callback(false, e); throw (e); }