diff --git a/packages/node_modules/pouchdb-core/src/adapter.js b/packages/node_modules/pouchdb-core/src/adapter.js index cc08c1fcf0..bf7a9c9ab7 100644 --- a/packages/node_modules/pouchdb-core/src/adapter.js +++ b/packages/node_modules/pouchdb-core/src/adapter.js @@ -197,6 +197,7 @@ function attachmentNameError(name) { class AbstractPouchDB extends EventEmitter { _setup() { + var pluginPrototype = Object.getPrototypeOf(this); this.post = adapterFun('post', function (doc, opts, callback) { if (typeof opts === 'function') { callback = opts; @@ -920,6 +921,13 @@ class AbstractPouchDB extends EventEmitter { Promise.all(deletedMap).then(destroyDb, callback); }); }).bind(this); + + // Re-add plugin methods that may have been overridden + for (var key in pluginPrototype) { + if (this[key] !== pluginPrototype[key]) { + this[key] = pluginPrototype[key]; + } + } } _compact(opts, callback) { diff --git a/tests/integration/test.basics.js b/tests/integration/test.basics.js index 946cb61736..37066a23c9 100644 --- a/tests/integration/test.basics.js +++ b/tests/integration/test.basics.js @@ -1205,6 +1205,12 @@ adapters.forEach(function (adapter) { }); } + it('#8594 Plugins can override core methods', function () { + PouchDB.plugin({bulkDocs: function () {return true;}}); + var db = new PouchDB("test"); + db.bulkDocs().should.equal(true); + }); + if (typeof process !== 'undefined' && !process.browser) { it('#5471 PouchDB.plugin() should throw error if passed wrong type or empty object', function () { (function () {