diff --git a/js/src/alert/alert.js b/js/src/alert/alert.js index 328aa16ae6..793b5989af 100644 --- a/js/src/alert/alert.js +++ b/js/src/alert/alert.js @@ -128,7 +128,7 @@ class Alert { // Static - static _jQueryInterface(config) { + static jQueryInterface(config) { return this.each(function () { let data = Data.getData(this, DATA_KEY) @@ -142,7 +142,7 @@ class Alert { }) } - static _handleDismiss(alertInstance) { + static handleDismiss(alertInstance) { return function (event) { if (event) { event.preventDefault() @@ -152,7 +152,7 @@ class Alert { } } - static _getInstance(element) { + static getInstance(element) { return Data.getData(element, DATA_KEY) } } @@ -163,7 +163,7 @@ class Alert { * ------------------------------------------------------------------------ */ EventHandler - .on(document, Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())) + .on(document, Event.CLICK_DATA_API, Selector.DISMISS, Alert.handleDismiss(new Alert())) /** * ------------------------------------------------------------------------ @@ -175,11 +175,11 @@ EventHandler /* istanbul ignore if */ if (typeof $ !== 'undefined') { const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Alert._jQueryInterface + $.fn[NAME] = Alert.jQueryInterface $.fn[NAME].Constructor = Alert $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT - return Alert._jQueryInterface + return Alert.jQueryInterface } } diff --git a/js/src/alert/alert.spec.js b/js/src/alert/alert.spec.js index 5cf314d222..05e3dbd686 100644 --- a/js/src/alert/alert.spec.js +++ b/js/src/alert/alert.spec.js @@ -117,15 +117,15 @@ describe('Alert', () => { const alertEl = document.querySelector('.alert') const alert = new Alert(alertEl) - expect(Alert._getInstance(alertEl)).toBeDefined() + expect(Alert.getInstance(alertEl)).toBeDefined() alert.dispose() - expect(Alert._getInstance(alertEl)).toBeNull() + expect(Alert.getInstance(alertEl)).toBeNull() }) }) - describe('_jQueryInterface', () => { + describe('jQueryInterface', () => { it('should handle config passed and toggle existing alert', () => { fixtureEl.innerHTML = '
' @@ -134,7 +134,7 @@ describe('Alert', () => { spyOn(alert, 'close') - jQueryMock.fn.alert = Alert._jQueryInterface + jQueryMock.fn.alert = Alert.jQueryInterface jQueryMock.elements = [alertEl] jQueryMock.fn.alert.call(jQueryMock, 'close') @@ -147,12 +147,12 @@ describe('Alert', () => { const alertEl = fixtureEl.querySelector('.alert') - jQueryMock.fn.alert = Alert._jQueryInterface + jQueryMock.fn.alert = Alert.jQueryInterface jQueryMock.elements = [alertEl] jQueryMock.fn.alert.call(jQueryMock, 'close') - expect(Alert._getInstance(alertEl)).toBeDefined() + expect(Alert.getInstance(alertEl)).toBeDefined() expect(fixtureEl.querySelector('.alert')).toBeNull() }) @@ -161,12 +161,12 @@ describe('Alert', () => { const alertEl = fixtureEl.querySelector('.alert') - jQueryMock.fn.alert = Alert._jQueryInterface + jQueryMock.fn.alert = Alert.jQueryInterface jQueryMock.elements = [alertEl] jQueryMock.fn.alert.call(jQueryMock) - expect(Alert._getInstance(alertEl)).toBeDefined() + expect(Alert.getInstance(alertEl)).toBeDefined() expect(fixtureEl.querySelector('.alert')).not.toBeNull() }) }) diff --git a/js/src/button/button.js b/js/src/button/button.js index 2e6033b64e..b7e20461d6 100644 --- a/js/src/button/button.js +++ b/js/src/button/button.js @@ -122,7 +122,7 @@ class Button { // Static - static _jQueryInterface(config) { + static jQueryInterface(config) { return this.each(function () { let data = Data.getData(this, DATA_KEY) @@ -136,7 +136,7 @@ class Button { }) } - static _getInstance(element) { + static getInstance(element) { return Data.getData(element, DATA_KEY) } } @@ -188,12 +188,12 @@ EventHandler.on(document, Event.BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, even /* istanbul ignore if */ if (typeof $ !== 'undefined') { const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Button._jQueryInterface + $.fn[NAME] = Button.jQueryInterface $.fn[NAME].Constructor = Button $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT - return Button._jQueryInterface + return Button.jQueryInterface } } diff --git a/js/src/button/button.spec.js b/js/src/button/button.spec.js index 7114088964..6228811854 100644 --- a/js/src/button/button.spec.js +++ b/js/src/button/button.spec.js @@ -236,15 +236,15 @@ describe('Button', () => { const btnEl = fixtureEl.querySelector('.btn') const button = new Button(btnEl) - expect(Button._getInstance(btnEl)).toBeDefined() + expect(Button.getInstance(btnEl)).toBeDefined() button.dispose() - expect(Button._getInstance(btnEl)).toBeNull() + expect(Button.getInstance(btnEl)).toBeNull() }) }) - describe('_jQueryInterface', () => { + describe('jQueryInterface', () => { it('should handle config passed and toggle existing button', () => { fixtureEl.innerHTML = '' @@ -253,7 +253,7 @@ describe('Button', () => { spyOn(button, 'toggle') - jQueryMock.fn.button = Button._jQueryInterface + jQueryMock.fn.button = Button.jQueryInterface jQueryMock.elements = [btnEl] jQueryMock.fn.button.call(jQueryMock, 'toggle') @@ -266,12 +266,12 @@ describe('Button', () => { const btnEl = fixtureEl.querySelector('.btn') - jQueryMock.fn.button = Button._jQueryInterface + jQueryMock.fn.button = Button.jQueryInterface jQueryMock.elements = [btnEl] jQueryMock.fn.button.call(jQueryMock, 'toggle') - expect(Button._getInstance(btnEl)).toBeDefined() + expect(Button.getInstance(btnEl)).toBeDefined() expect(btnEl.classList.contains('active')).toEqual(true) }) @@ -280,12 +280,12 @@ describe('Button', () => { const btnEl = fixtureEl.querySelector('.btn') - jQueryMock.fn.button = Button._jQueryInterface + jQueryMock.fn.button = Button.jQueryInterface jQueryMock.elements = [btnEl] jQueryMock.fn.button.call(jQueryMock) - expect(Button._getInstance(btnEl)).toBeDefined() + expect(Button.getInstance(btnEl)).toBeDefined() expect(btnEl.classList.contains('active')).toEqual(false) }) }) diff --git a/js/src/carousel/carousel.js b/js/src/carousel/carousel.js index af4229f07c..0bac655ea0 100644 --- a/js/src/carousel/carousel.js +++ b/js/src/carousel/carousel.js @@ -528,7 +528,7 @@ class Carousel { // Static - static _carouselInterface(element, config) { + static carouselInterface(element, config) { let data = Data.getData(element, DATA_KEY) let _config = { ...Default, @@ -562,13 +562,13 @@ class Carousel { } } - static _jQueryInterface(config) { + static jQueryInterface(config) { return this.each(function () { - Carousel._carouselInterface(this, config) + Carousel.carouselInterface(this, config) }) } - static _dataApiClickHandler(event) { + static dataApiClickHandler(event) { const target = getElementFromSelector(this) if (!target || !target.classList.contains(ClassName.CAROUSEL)) { @@ -585,7 +585,7 @@ class Carousel { config.interval = false } - Carousel._carouselInterface(target, config) + Carousel.carouselInterface(target, config) if (slideIndex) { Data.getData(target, DATA_KEY).to(slideIndex) @@ -594,7 +594,7 @@ class Carousel { event.preventDefault() } - static _getInstance(element) { + static getInstance(element) { return Data.getData(element, DATA_KEY) } } @@ -606,12 +606,12 @@ class Carousel { */ EventHandler - .on(document, Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler) + .on(document, Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel.dataApiClickHandler) EventHandler.on(window, Event.LOAD_DATA_API, () => { const carousels = makeArray(SelectorEngine.find(Selector.DATA_RIDE)) for (let i = 0, len = carousels.length; i < len; i++) { - Carousel._carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY)) + Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY)) } }) @@ -624,11 +624,11 @@ EventHandler.on(window, Event.LOAD_DATA_API, () => { /* istanbul ignore if */ if (typeof $ !== 'undefined') { const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Carousel._jQueryInterface + $.fn[NAME] = Carousel.jQueryInterface $.fn[NAME].Constructor = Carousel $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT - return Carousel._jQueryInterface + return Carousel.jQueryInterface } } diff --git a/js/src/carousel/carousel.spec.js b/js/src/carousel/carousel.spec.js index 38888e7c2c..4c13b6d227 100644 --- a/js/src/carousel/carousel.spec.js +++ b/js/src/carousel/carousel.spec.js @@ -1037,18 +1037,18 @@ describe('Carousel', () => { }) }) - describe('_jQueryInterface', () => { + describe('jQueryInterface', () => { it('should create a carousel', () => { fixtureEl.innerHTML = '
' const div = fixtureEl.querySelector('div') - jQueryMock.fn.carousel = Carousel._jQueryInterface + jQueryMock.fn.carousel = Carousel.jQueryInterface jQueryMock.elements = [div] jQueryMock.fn.carousel.call(jQueryMock) - expect(Carousel._getInstance(div)).toBeDefined() + expect(Carousel.getInstance(div)).toBeDefined() }) it('should not re create a carousel', () => { @@ -1057,12 +1057,12 @@ describe('Carousel', () => { const div = fixtureEl.querySelector('div') const carousel = new Carousel(div) - jQueryMock.fn.carousel = Carousel._jQueryInterface + jQueryMock.fn.carousel = Carousel.jQueryInterface jQueryMock.elements = [div] jQueryMock.fn.carousel.call(jQueryMock) - expect(Carousel._getInstance(div)).toEqual(carousel) + expect(Carousel.getInstance(div)).toEqual(carousel) }) it('should call to if the config is a number', () => { @@ -1074,7 +1074,7 @@ describe('Carousel', () => { spyOn(carousel, 'to') - jQueryMock.fn.carousel = Carousel._jQueryInterface + jQueryMock.fn.carousel = Carousel.jQueryInterface jQueryMock.elements = [div] jQueryMock.fn.carousel.call(jQueryMock, slideTo) @@ -1088,7 +1088,7 @@ describe('Carousel', () => { const div = fixtureEl.querySelector('div') const action = 'undefinedMethod' - jQueryMock.fn.carousel = Carousel._jQueryInterface + jQueryMock.fn.carousel = Carousel.jQueryInterface jQueryMock.elements = [div] try { @@ -1108,7 +1108,7 @@ describe('Carousel', () => { window.dispatchEvent(loadEvent) - expect(Carousel._getInstance(carouselEl)).toBeDefined() + expect(Carousel.getInstance(carouselEl)).toBeDefined() }) it('should create carousel and go to the next slide on click', done => { diff --git a/js/src/collapse/collapse.js b/js/src/collapse/collapse.js index c1d9aa2f1b..7990857763 100644 --- a/js/src/collapse/collapse.js +++ b/js/src/collapse/collapse.js @@ -173,7 +173,7 @@ class Collapse { if (actives) { actives.forEach(elemActive => { if (container !== elemActive) { - Collapse._collapseInterface(elemActive, 'hide') + Collapse.collapseInterface(elemActive, 'hide') } if (!activesData) { @@ -348,7 +348,7 @@ class Collapse { // Static - static _collapseInterface(element, config) { + static collapseInterface(element, config) { let data = Data.getData(element, DATA_KEY) const _config = { ...Default, @@ -373,13 +373,13 @@ class Collapse { } } - static _jQueryInterface(config) { + static jQueryInterface(config) { return this.each(function () { - Collapse._collapseInterface(this, config) + Collapse.collapseInterface(this, config) }) } - static _getInstance(element) { + static getInstance(element) { return Data.getData(element, DATA_KEY) } } @@ -415,7 +415,7 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function ( config = triggerData } - Collapse._collapseInterface(element, config) + Collapse.collapseInterface(element, config) }) }) @@ -428,11 +428,11 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function ( /* istanbul ignore if */ if (typeof $ !== 'undefined') { const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Collapse._jQueryInterface + $.fn[NAME] = Collapse.jQueryInterface $.fn[NAME].Constructor = Collapse $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT - return Collapse._jQueryInterface + return Collapse.jQueryInterface } } diff --git a/js/src/collapse/collapse.spec.js b/js/src/collapse/collapse.spec.js index 731b4a25f8..154bc2c6bb 100644 --- a/js/src/collapse/collapse.spec.js +++ b/js/src/collapse/collapse.spec.js @@ -366,11 +366,11 @@ describe('Collapse', () => { toggle: false }) - expect(Collapse._getInstance(collapseEl)).toEqual(collapse) + expect(Collapse.getInstance(collapseEl)).toEqual(collapse) collapse.dispose() - expect(Collapse._getInstance(collapseEl)).toEqual(null) + expect(Collapse.getInstance(collapseEl)).toEqual(null) }) }) @@ -760,18 +760,18 @@ describe('Collapse', () => { }) }) - describe('_jQueryInterface', () => { + describe('jQueryInterface', () => { it('should create a collapse', () => { fixtureEl.innerHTML = '
' const div = fixtureEl.querySelector('div') - jQueryMock.fn.collapse = Collapse._jQueryInterface + jQueryMock.fn.collapse = Collapse.jQueryInterface jQueryMock.elements = [div] jQueryMock.fn.collapse.call(jQueryMock) - expect(Collapse._getInstance(div)).toBeDefined() + expect(Collapse.getInstance(div)).toBeDefined() }) it('should not re create a collapse', () => { @@ -780,12 +780,12 @@ describe('Collapse', () => { const div = fixtureEl.querySelector('div') const collapse = new Collapse(div) - jQueryMock.fn.collapse = Collapse._jQueryInterface + jQueryMock.fn.collapse = Collapse.jQueryInterface jQueryMock.elements = [div] jQueryMock.fn.collapse.call(jQueryMock) - expect(Collapse._getInstance(div)).toEqual(collapse) + expect(Collapse.getInstance(div)).toEqual(collapse) }) it('should throw error on undefined method', () => { @@ -794,7 +794,7 @@ describe('Collapse', () => { const div = fixtureEl.querySelector('div') const action = 'undefinedMethod' - jQueryMock.fn.collapse = Collapse._jQueryInterface + jQueryMock.fn.collapse = Collapse.jQueryInterface jQueryMock.elements = [div] try { @@ -805,14 +805,14 @@ describe('Collapse', () => { }) }) - describe('_getInstance', () => { + describe('getInstance', () => { it('should return collapse instance', () => { fixtureEl.innerHTML = '
' const div = fixtureEl.querySelector('div') const collapse = new Collapse(div) - expect(Collapse._getInstance(div)).toEqual(collapse) + expect(Collapse.getInstance(div)).toEqual(collapse) }) it('should return null when there is no collapse instance', () => { @@ -820,7 +820,7 @@ describe('Collapse', () => { const div = fixtureEl.querySelector('div') - expect(Collapse._getInstance(div)).toEqual(null) + expect(Collapse.getInstance(div)).toEqual(null) }) }) }) diff --git a/js/src/dropdown/dropdown.js b/js/src/dropdown/dropdown.js index f30c3924b3..7f5264d050 100644 --- a/js/src/dropdown/dropdown.js +++ b/js/src/dropdown/dropdown.js @@ -133,10 +133,10 @@ class Dropdown { return } - const parent = Dropdown._getParentFromElement(this._element) + const parent = Dropdown.getParentFromElement(this._element) const isActive = this._menu.classList.contains(ClassName.SHOW) - Dropdown._clearMenus() + Dropdown.clearMenus() if (isActive) { return @@ -207,7 +207,7 @@ class Dropdown { return } - const parent = Dropdown._getParentFromElement(this._element) + const parent = Dropdown.getParentFromElement(this._element) const relatedTarget = { relatedTarget: this._element } @@ -228,7 +228,7 @@ class Dropdown { return } - const parent = Dropdown._getParentFromElement(this._element) + const parent = Dropdown.getParentFromElement(this._element) const relatedTarget = { relatedTarget: this._element } @@ -289,7 +289,7 @@ class Dropdown { } _getMenuElement() { - const parent = Dropdown._getParentFromElement(this._element) + const parent = Dropdown.getParentFromElement(this._element) return SelectorEngine.findOne(Selector.MENU, parent) } @@ -364,7 +364,7 @@ class Dropdown { // Static - static _dropdownInterface(element, config) { + static dropdownInterface(element, config) { let data = Data.getData(element, DATA_KEY) const _config = typeof config === 'object' ? config : null @@ -381,13 +381,13 @@ class Dropdown { } } - static _jQueryInterface(config) { + static jQueryInterface(config) { return this.each(function () { - Dropdown._dropdownInterface(this, config) + Dropdown.dropdownInterface(this, config) }) } - static _clearMenus(event) { + static clearMenus(event) { if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) { return @@ -395,7 +395,7 @@ class Dropdown { const toggles = makeArray(SelectorEngine.find(Selector.DATA_TOGGLE)) for (let i = 0, len = toggles.length; i < len; i++) { - const parent = Dropdown._getParentFromElement(toggles[i]) + const parent = Dropdown.getParentFromElement(toggles[i]) const context = Data.getData(toggles[i], DATA_KEY) const relatedTarget = { relatedTarget: toggles[i] @@ -441,11 +441,11 @@ class Dropdown { } } - static _getParentFromElement(element) { + static getParentFromElement(element) { return getElementFromSelector(element) || element.parentNode } - static _dataApiKeydownHandler(event) { + static dataApiKeydownHandler(event) { // If not input/textarea: // - And not a key in REGEXP_KEYDOWN => not a dropdown command // If input/textarea: @@ -468,7 +468,7 @@ class Dropdown { return } - const parent = Dropdown._getParentFromElement(this) + const parent = Dropdown.getParentFromElement(this) const isActive = parent.classList.contains(ClassName.SHOW) if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { @@ -476,7 +476,7 @@ class Dropdown { SelectorEngine.findOne(Selector.DATA_TOGGLE, parent).focus() } - Dropdown._clearMenus() + Dropdown.clearMenus() return } @@ -503,7 +503,7 @@ class Dropdown { items[index].focus() } - static _getInstance(element) { + static getInstance(element) { return Data.getData(element, DATA_KEY) } } @@ -514,14 +514,14 @@ class Dropdown { * ------------------------------------------------------------------------ */ -EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler) -EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler) -EventHandler.on(document, Event.CLICK_DATA_API, Dropdown._clearMenus) -EventHandler.on(document, Event.KEYUP_DATA_API, Dropdown._clearMenus) +EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown.dataApiKeydownHandler) +EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown.dataApiKeydownHandler) +EventHandler.on(document, Event.CLICK_DATA_API, Dropdown.clearMenus) +EventHandler.on(document, Event.KEYUP_DATA_API, Dropdown.clearMenus) EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { event.preventDefault() event.stopPropagation() - Dropdown._dropdownInterface(this, 'toggle') + Dropdown.dropdownInterface(this, 'toggle') }) EventHandler .on(document, Event.CLICK_DATA_API, Selector.FORM_CHILD, e => e.stopPropagation()) @@ -535,11 +535,11 @@ EventHandler /* istanbul ignore if */ if (typeof $ !== 'undefined') { const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Dropdown._jQueryInterface + $.fn[NAME] = Dropdown.jQueryInterface $.fn[NAME].Constructor = Dropdown $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT - return Dropdown._jQueryInterface + return Dropdown.jQueryInterface } } diff --git a/js/src/dropdown/dropdown.spec.js b/js/src/dropdown/dropdown.spec.js index 2d9719d5da..92d8fea033 100644 --- a/js/src/dropdown/dropdown.spec.js +++ b/js/src/dropdown/dropdown.spec.js @@ -1412,18 +1412,18 @@ describe('Dropdown', () => { }) }) - describe('_jQueryInterface', () => { + describe('jQueryInterface', () => { it('should create a dropdown', () => { fixtureEl.innerHTML = '
' const div = fixtureEl.querySelector('div') - jQueryMock.fn.dropdown = Dropdown._jQueryInterface + jQueryMock.fn.dropdown = Dropdown.jQueryInterface jQueryMock.elements = [div] jQueryMock.fn.dropdown.call(jQueryMock) - expect(Dropdown._getInstance(div)).toBeDefined() + expect(Dropdown.getInstance(div)).toBeDefined() }) it('should not re create a dropdown', () => { @@ -1432,12 +1432,12 @@ describe('Dropdown', () => { const div = fixtureEl.querySelector('div') const dropdown = new Dropdown(div) - jQueryMock.fn.dropdown = Dropdown._jQueryInterface + jQueryMock.fn.dropdown = Dropdown.jQueryInterface jQueryMock.elements = [div] jQueryMock.fn.dropdown.call(jQueryMock) - expect(Dropdown._getInstance(div)).toEqual(dropdown) + expect(Dropdown.getInstance(div)).toEqual(dropdown) }) it('should throw error on undefined method', () => { @@ -1446,7 +1446,7 @@ describe('Dropdown', () => { const div = fixtureEl.querySelector('div') const action = 'undefinedMethod' - jQueryMock.fn.dropdown = Dropdown._jQueryInterface + jQueryMock.fn.dropdown = Dropdown.jQueryInterface jQueryMock.elements = [div] try { @@ -1457,14 +1457,14 @@ describe('Dropdown', () => { }) }) - describe('_getInstance', () => { + describe('getInstance', () => { it('should return dropdown instance', () => { fixtureEl.innerHTML = '
' const div = fixtureEl.querySelector('div') const dropdown = new Dropdown(div) - expect(Dropdown._getInstance(div)).toEqual(dropdown) + expect(Dropdown.getInstance(div)).toEqual(dropdown) }) it('should return null when there is no dropdown instance', () => { @@ -1472,7 +1472,7 @@ describe('Dropdown', () => { const div = fixtureEl.querySelector('div') - expect(Dropdown._getInstance(div)).toEqual(null) + expect(Dropdown.getInstance(div)).toEqual(null) }) }) }) diff --git a/js/src/modal/modal.js b/js/src/modal/modal.js index 5d74249374..fd24b7768f 100644 --- a/js/src/modal/modal.js +++ b/js/src/modal/modal.js @@ -513,7 +513,7 @@ class Modal { // Static - static _jQueryInterface(config, relatedTarget) { + static jQueryInterface(config, relatedTarget) { return this.each(function () { let data = Data.getData(this, DATA_KEY) const _config = { @@ -538,7 +538,7 @@ class Modal { }) } - static _getInstance(element) { + static getInstance(element) { return Data.getData(element, DATA_KEY) } } @@ -591,11 +591,11 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function ( /* istanbul ignore if */ if (typeof $ !== 'undefined') { const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Modal._jQueryInterface + $.fn[NAME] = Modal.jQueryInterface $.fn[NAME].Constructor = Modal $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT - return Modal._jQueryInterface + return Modal.jQueryInterface } } diff --git a/js/src/modal/modal.spec.js b/js/src/modal/modal.spec.js index 5111f00a9a..5623d174c6 100644 --- a/js/src/modal/modal.spec.js +++ b/js/src/modal/modal.spec.js @@ -711,13 +711,13 @@ describe('Modal', () => { const modalEl = fixtureEl.querySelector('.modal') const modal = new Modal(modalEl) - expect(Modal._getInstance(modalEl)).toEqual(modal) + expect(Modal.getInstance(modalEl)).toEqual(modal) spyOn(EventHandler, 'off') modal.dispose() - expect(Modal._getInstance(modalEl)).toEqual(null) + expect(Modal.getInstance(modalEl)).toEqual(null) expect(EventHandler.off).toHaveBeenCalledTimes(4) }) }) @@ -813,7 +813,7 @@ describe('Modal', () => { spyOn(trigger, 'focus') modalEl.addEventListener('shown.bs.modal', () => { - const modal = Modal._getInstance(modalEl) + const modal = Modal.getInstance(modalEl) modal.hide() }) @@ -844,7 +844,7 @@ describe('Modal', () => { spyOn(trigger, 'focus') modalEl.addEventListener('shown.bs.modal', () => { - const modal = Modal._getInstance(modalEl) + const modal = Modal.getInstance(modalEl) modal.hide() }) @@ -890,18 +890,18 @@ describe('Modal', () => { }) }) - describe('_jQueryInterface', () => { + describe('jQueryInterface', () => { it('should create a modal', () => { fixtureEl.innerHTML = '