From 6126a49feab63ca29d5a9ab500d2ae845cda8b03 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 25 Apr 2015 03:05:54 -0400 Subject: [PATCH] Don't require non-identified items to have loaded data in getField() This allows getField() on an unsaved item to work properly without a pointless loadItemData() call. --- chrome/content/zotero/xpcom/data/item.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 346dcf39c..0ddabd837 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -267,10 +267,9 @@ Zotero.Item.prototype.getField = function(field, unformatted, includeBaseMapped) return ''; } - // Either item data has to be loaded (which sets empty valid fields to false) - // or this field has to be populated (e.g., by Zotero.Items.cacheFields()) - // before getField() is called. - if (value === null) { + // If the item is identified (has an id or key), this field has to be populated (e.g., by + // Zotero.Items.cacheFields()) or item data has to be loaded + if (this._identified && value === null && !this._loaded.itemData) { throw new Zotero.Exception.UnloadedDataException( "Item data not loaded and field '" + field + "' not set", "itemData" );