From 79486040d42c9d273eb45012b2296d90be8008de Mon Sep 17 00:00:00 2001 From: adam3smith Date: Sun, 23 Oct 2016 12:17:15 -0400 Subject: [PATCH] Use splice instead of delete to remove attachments Fixes https://forums.zotero.org/discussion/62917/report-id-985863464-error#latest @zuphilip -- this is Aurimas's code, but I think I've seen you use delete for arrays in translators? It's typically not the right choice. See http://stackoverflow.com/a/5767335 --- Embedded Metadata.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Embedded Metadata.js b/Embedded Metadata.js index 43115fc5a4..b57aafa4ab 100644 --- a/Embedded Metadata.js +++ b/Embedded Metadata.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2016-09-08 07:14:24" + "lastUpdated": "2016-10-23 15:17:12" } /* @@ -479,15 +479,15 @@ function addHighwireMetadata(doc, newItem) { pdfURL = pdfURL[0].textContent; //delete any pdf attachments if present //would it be ok to just delete all attachments?? - for(var i=0, n=newItem.attachments.length; i=0; i--) { if(newItem.attachments[i].mimeType == 'application/pdf') { - delete newItem.attachments[i]; + newItem.attachments.splice(i, 1); } } newItem.attachments.push({title:"Full Text PDF", url:pdfURL, mimeType:"application/pdf"}); } - + //add snapshot newItem.attachments.push({document:doc, title:"Snapshot"}); @@ -1296,4 +1296,4 @@ var testCases = [ ] } ] -/** END TEST CASES **/ \ No newline at end of file +/** END TEST CASES **/