diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 78ad80371..bd93b2bb0 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -290,18 +290,14 @@ class Dropdown extends BaseComponent { } _getOffset() { - let { offset } = this._config - - if (!offset) { - return [0, 0] - } + const { offset } = this._config if (typeof offset === 'string') { - offset = offset.split(',').map(val => Number.parseInt(val, 10)) - } else if (typeof offset === 'function') { - offset = ({ popper, reference, placement }) => { - return offset({ popper, reference, placement }, this._element) - } + return offset.split(',').map(val => Number.parseInt(val, 10)) + } + + if (typeof offset === 'function') { + return popperData => offset(popperData, this._element) } return offset diff --git a/js/tests/unit/dropdown.spec.js b/js/tests/unit/dropdown.spec.js index c59cd3b02..0b7e1621f 100644 --- a/js/tests/unit/dropdown.spec.js +++ b/js/tests/unit/dropdown.spec.js @@ -54,7 +54,7 @@ describe('Dropdown', () => { expect(dropdown.toggle).toHaveBeenCalled() }) - it('should create offset modifier correctly when offset option is a function', () => { + it('should create offset modifier correctly when offset option is a function', done => { fixtureEl.innerHTML = [ '