ng-pouchdb icon indicating copy to clipboard operation
ng-pouchdb copied to clipboard

Changes listener does not remove last item of collection

Open picard315 opened this issue 10 years ago • 1 comments

I don't know why this happens, but i deleted the last item of a collection using the couchdb web interface. Strangely the browser seems to skip the removeChild command in the following block:

          } else if (collection.length && indexes[change.id]) { //DELETE
            removeChild(change.id);
            updateIndexes(indexes[change.id]);
          }

Happened on Firefox 38.0 on CentOS.

Replacing the condition with collection.length && (indexes[change.id] != undefined) fixes the issue.

picard315 avatar Jun 10 '15 21:06 picard315

Additional info: When adding the fix from issue #6 it will still not remove the last item in the collection.

picard315 avatar Jun 10 '15 21:06 picard315