Juris-M / citeproc-js

A JavaScript implementation of the Citation Style Language (CSL) https://citeproc-js.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

updateUncitedItems does not purge unlisted uncited items when no citation were ever done

dgervalle opened this issue · comments

According to the documentation of updateUncitedItems, uncited items not listed in the argument are removed from the registry.

In registry.js, the doPurge method contains the condition:

CSL.Registry.prototype.dopurge = function (myhash) {
...
        if (this.citationreg.citationsByItemId) {
            if (!this.citationreg.citationsByItemId[this.mylist[i]] && !myhash[this.mylist[i]]) {
...
};

With such condition on the availability of this.citationreg.citationsByItemId, no uncited item would be deleted if there where no citation so far. IMO, the condition should be updated like this:

CSL.Registry.prototype.dopurge = function (myhash) {
...
        if ((!this.citationreg.citationsByItemId || !this.citationreg.citationsByItemId[this.mylist[i]]) && !myhash[this.mylist[i]]) {
...
};

So that, if no citation where done so far, all uncited items that are unlisted are removed properly from the registry.
To also cleanup the uncited array, I would also add inside that condition:

delete this.uncited[this.mylist[i]];

If you don't see any cons, I would be pleased if you could integrate those changes, so that I avoid a fork for such a minor change.

Thanks for this report, and for the recommended fix. I will merge this.

Adopted in 2a133d2