diff --git a/chrome/content/zotero/xpcom/annotations.js b/chrome/content/zotero/xpcom/annotations.js index edc1b2f32e..4b69440376 100644 --- a/chrome/content/zotero/xpcom/annotations.js +++ b/chrome/content/zotero/xpcom/annotations.js @@ -50,7 +50,8 @@ Zotero.Annotations = new function () { o.pageLabel = item.annotationPageLabel; o.color = item.annotationColor; o.sortIndex = item.annotationSortIndex; - o.position = item.annotationPosition; + // annotationPosition is a JSON string, but we want to pass the raw object to the reader + o.position = JSON.parse(item.annotationPosition); // Add tags and tag colors var tagColors = Zotero.Tags.getColors(item.libraryID); diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 631f3cbc97..b1fde27b17 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -566,13 +566,7 @@ Zotero.Items = function() { throw new Error("Item " + itemID + " not found"); } - try { - item._annotationPosition = JSON.parse(row.getResultByIndex(1)); - } - catch (e) { - Zotero.logError(`Error parsing 'position' for item ${item.libraryKey}`); - item._annotationPosition = {}; - } + item._annotationPosition = row.getResultByIndex(1); item._annotationPageLabel = row.getResultByIndex(2); item._loaded.annotationDeferred = true; diff --git a/test/tests/annotationsTest.js b/test/tests/annotationsTest.js index f436021d91..3875c5e635 100644 --- a/test/tests/annotationsTest.js +++ b/test/tests/annotationsTest.js @@ -143,7 +143,7 @@ describe("Zotero.Annotations", function() { if (prop == 'dateModified') { continue; } - assert.deepEqual(json[prop], exampleHighlightAlt[prop], `'${prop}' doesn't match`); + assert.deepEqual(json[prop], exampleHighlight[prop], `'${prop}' doesn't match`); } await annotation.eraseTx(); @@ -168,7 +168,7 @@ describe("Zotero.Annotations", function() { if (prop == 'dateModified') { continue; } - assert.deepEqual(json[prop], exampleNoteAlt[prop], `'${prop}' doesn't match`); + assert.deepEqual(json[prop], exampleNote[prop], `'${prop}' doesn't match`); } await annotation.eraseTx(); @@ -207,7 +207,7 @@ describe("Zotero.Annotations", function() { || prop == 'dateModified') { continue; } - assert.deepEqual(json[prop], exampleImageAlt[prop], `'${prop}' doesn't match`); + assert.deepEqual(json[prop], exampleImage[prop], `'${prop}' doesn't match`); } assert.equal(json.imageURL, `zotero://attachment/library/items/${imageAttachment.key}`);