commit 5a1cf3ab02d8e992279d3a0ce3f6d63c2d803291
parent 3f905be77e2c2f89ea4e5382d69790eddf938b57
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date: Mon, 5 Mar 2018 13:46:46 +0200
Fix dead integration field object function calls
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
@@ -1130,7 +1130,7 @@ Zotero.Integration.Fields.prototype.addEditCitation = Zotero.Promise.coroutine(f
if (fields[i].equals(field._field)) {
// This is needed, because LibreOffice integration plugin caches the field code instead of asking
// the document every time when calling #getCode().
- field._field = fields[i];
+ field = new Zotero.Integration.CitationField(fields[i]);
return i;
}
}
@@ -1967,10 +1967,9 @@ Zotero.Integration.Field = class {
if (field instanceof Zotero.Integration.Field) {
throw new Error("Trying to instantiate Integration.Field with Integration.Field, not doc field");
}
- // This is not the best solution in terms of performance
- for (let prop in field) {
- if (prop[0] != '_' && !(prop in this)) {
- this[prop] = field[prop].bind ? field[prop].bind(field) : field[prop];
+ for (let func of Zotero.Integration.Field.INTERFACE) {
+ if (!(func in this)) {
+ this[func] = field[func].bind(field);
}
}
this._field = field;
@@ -2018,6 +2017,8 @@ Zotero.Integration.Field = class {
return isRich;
}
};
+Zotero.Integration.Field.INTERFACE = ['delete', 'removeCode', 'select', 'setText',
+ 'getText', 'setCode', 'getCode', 'equals', 'getNoteIndex'];
/**
* Load existing field in document and return correct instance of field type